Loading...
Searching...
No Matches
htable.h File Reference
`#include "kernel/mod2.h"`
`#include "Singular/subexpr.h"`

Go to the source code of this file.

## Data Structures

struct | telem
struct | stablerec

## Macros

#define | TABLE_MAX 1000

## Functions

stablerec * | t_createTable (int s)
void | t_destroyTable (stablerec *t)
stablerec * | copyTable (stablerec *t)
char * | stringTable (stablerec *t)
void | htable_Print (stablerec *d)
telem | t_findTable (stablerec *t, const char *s)
| find the entry to key s
leftv | t_findTabelVal (stablerec *t, const char *s)
| find the data to key s
void | t_addTable (stablerec *t, char *s, leftv v)
| add a new entry (key s, data v) to table t

## Data Structure Documentation

## stelem

struct stelem

Definition at line 14 of file htable.h.

Data Fields
uint32_t | hash |
char * | key |
telem | next |
sleftv | val |

## stablerec

struct stablerec

Definition at line 22 of file htable.h.

Data Fields
int | max |
int | ref |
telem * | t |

## Macro Definition Documentation

## TABLE_MAX

#define TABLE_MAX 1000

Definition at line 28 of file htable.h.

## Function Documentation

## copyTable()

stablerec * copyTable | ( | stablerec * | t | ) |

Definition at line 42 of file htable.cc.

{
t->ref++;
return t;
}
stablerec::ref
int ref
Definition htable.h:26

## htable_Print()

void htable_Print | ( | stablerec * | d | ) |

Definition at line 108 of file htable.cc.

{
stablerec* lt=(stablerec*)d;
char* s=stringTable(lt);
PrintS(s);
omFree(s);
int cnt=0;int cnt2=0;
for(int i=0;i<lt->max;i++)
{
if (lt->t[i]!=NULL)
{
cnt++;
telem p=lt->t[i];
while(p!=NULL) { cnt2++;p=p->next;}
}
}
Print("%d columns, %d entries, size:%d",cnt,cnt2,lt->max);
}
i
int i
Definition cfEzgcd.cc:132
p
int p
Definition cfModGcd.cc:4086
Print
#define Print
Definition emacs.cc:80
s
const CanonicalForm int s
Definition facAbsFact.cc:51
stringTable
char * stringTable(stablerec *t)
Definition htable.cc:48
stablerec::t
telem * t
Definition htable.h:24
stablerec::max
int max
Definition htable.h:25
stablerec
Definition htable.h:23
omFree
#define omFree(addr)
Definition omAllocDecl.h:261
NULL
#define NULL
Definition omList.c:12
PrintS
void PrintS(const char *s)
Definition reporter.cc:288

## stringTable()

char * stringTable | ( | stablerec * | t | ) |

Definition at line 48 of file htable.cc.

{
StringSetS("table:\n");
char *s;
for(int i=t->max-1;i>=0;i--)
{
telem p=t->t[i];
while(p!=NULL)
{
StringAppendS(p->key);
StringAppendS(" -> ");
s=p->val.String();
StringAppendS(s);
omFree(s);
StringAppendS("\n");
telem pp=p;
p=p->next;
}
}
return StringEndS();
}
pp
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f ).
Definition cf_gcd.cc:676
StringSetS
void StringSetS(const char *st)
Definition reporter.cc:128
StringAppendS
void StringAppendS(const char *st)
Definition reporter.cc:107
StringEndS
char * StringEndS()
Definition reporter.cc:151

## t_addTable()

void t_addTable | ( | stablerec * | t,
|  | char * | s,
|  | leftv | v )

add a new entry (key s, data v) to table t

add a new entry (key s, data v) to table t

Definition at line 93 of file htable.cc.

{
uint32_t h=hashlittle(s,strlen(s));
telem p=(telem)omAlloc(sizeof(*p));
p->next=NULL;
p->key=s;
p->val.Init();
p->val.rtyp=v->Typ();
p->val.data=v->CopyD();
p->hash=h;
h=h%t->max;
p->next=t->t[h];
t->t[h]=p;
}
v
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
hashlittle
uint32_t hashlittle(const void *key, size_t length)
Definition hash_me.c:68
h
STATIC_VAR Poly * h
Definition janet.cc:971
omAlloc
#define omAlloc(size)
Definition omAllocDecl.h:210

## t_createTable()

stablerec * t_createTable | ( | int | s | ) |

Definition at line 11 of file htable.cc.

{
stablerec* t=(stablerec*)omAlloc(sizeof(stablerec));
t->max=s;
t->t=(telem*)omAlloc0(s*sizeof(telem));
t->ref=1;
return t;
}
omAlloc0
#define omAlloc0(size)
Definition omAllocDecl.h:211

## t_destroyTable()

void t_destroyTable | ( | stablerec * | t | ) |

Definition at line 20 of file htable.cc.

{
t->ref--;
if (t->ref<=0)
{
for(int i=t->max-1;i>=0;i--)
{
telem p=t->t[i];
while(p!=NULL)
{
omFree(p->key);
p->val.CleanUp();
telem pp=p;
p=p->next;
omFreeSize(pp,sizeof(stelem));
}
}
omFreeSize(t->t,t->max*sizeof(telem));
omFreeSize(t,sizeof(stablerec));
}
}
stelem
Definition htable.h:15
omFreeSize
#define omFreeSize(addr, size)
Definition omAllocDecl.h:260

## t_findTabelVal()

leftv t_findTabelVal | ( | stablerec * | t,
|  | const char * | s )

find the data to key s

Definition at line 85 of file htable.cc.

{
telem p=t_findTable(t,s);
if (p==NULL) return NULL;
return &(p->val);
}
t_findTable
telem t_findTable(stablerec *t, const char *s)
find the entry to key s
Definition htable.cc:71

## t_findTable()

telem t_findTable | ( | stablerec * | t,
|  | const char * | s )

find the entry to key s

Definition at line 71 of file htable.cc.

{
uint32_t h=hashlittle(s,strlen(s));
h=h%t->max;
telem p=t->t[h];
while(p!=NULL)
{
if (strcmp(s,p->key)==0) return p;
p=p->next;
}
return NULL;
}