My Project
Loading...
Searching...
No Matches
Data Structures | Functions
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
 

Functions

stablerect_createTable (int s)
 
void t_destroyTable (stablerec *t)
 
stablereccopyTable (stablerec *t)
 
charstringTable (stablerec *t)
 
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, const 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

Function Documentation

◆ copyTable()

stablerec * copyTable ( stablerec t)

Definition at line 40 of file htable.cc.

41{
42 t->ref++;
43 return t;
44}
int ref
Definition htable.h:26

◆ stringTable()

char * stringTable ( stablerec t)

Definition at line 46 of file htable.cc.

47{
48 StringSetS("table:\n");
49 for(int i=t->max-1;i>=0;i--)
50 {
51 telem p=t->t[i];
52 while(p!=NULL)
53 {
54 StringAppendS(p->key);
55 StringAppendS("->");
56 StringAppendS(p->val.String());
57 StringAppendS("\n");
58 telem pp=p;
59 p=p->next;
60 }
61 return StringEndS();
62 }
63}
CanonicalForm FACTORY_PUBLIC pp(const CanonicalForm &)
CanonicalForm pp ( const CanonicalForm & f )
Definition cf_gcd.cc:676
int i
Definition cfEzgcd.cc:132
int p
Definition cfModGcd.cc:4086
telem * t
Definition htable.h:24
int max
Definition htable.h:25
#define NULL
Definition omList.c:12
void StringSetS(const char *st)
Definition reporter.cc:128
void StringAppendS(const char *st)
Definition reporter.cc:107
char * StringEndS()
Definition reporter.cc:151

◆ t_addTable()

void t_addTable ( stablerec t,
const char s,
leftv  v 
)

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

Definition at line 88 of file htable.cc.

89{
91 telem p=(telem)omAlloc(sizeof(stelem));
92 p->next=NULL;
93 p->key=omStrDup(s);
94 p->val.Copy(v);
95 p->hash=h;
96 h=h%t->max;
97 p->next=t->t[h];
98 t->t[h]=p;
99}
const CanonicalForm int s
Definition facAbsFact.cc:51
const Variable & v
< [in] a sqrfree bivariate poly
Definition facBivar.h:39
uint32_t hashlittle(const void *key, size_t length)
Definition hash_me.c:68
STATIC_VAR Poly * h
Definition janet.cc:971
#define omStrDup(s)
#define omAlloc(size)

◆ t_createTable()

stablerec * t_createTable ( int  s)

Definition at line 11 of file htable.cc.

12{
14 t->max=s;
15 t->t=(telem*)omAlloc0(s*sizeof(telem));
16 t->ref=1;
17 return t;
18}
#define omAlloc0(size)

◆ t_destroyTable()

void t_destroyTable ( stablerec t)

Definition at line 20 of file htable.cc.

21{
22 t->ref--;
23 if (t->ref<=0)
24 {
25 for(int i=t->max-1;i>=0;i--)
26 {
27 telem p=t->t[i];
28 while(p!=NULL)
29 {
30 omFree(p->key);
31 p->val.CleanUp();
32 telem pp=p;
33 p=p->next;
34 omFreeSize(pp,sizeof(stelem));
35 }
36 }
37 }
38}
#define omFreeSize(addr, size)
#define omFree(addr)

◆ t_findTabelVal()

leftv t_findTabelVal ( stablerec t,
const char s 
)

find the data to key s

Definition at line 80 of file htable.cc.

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

◆ t_findTable()

telem t_findTable ( stablerec t,
const char s 
)

find the entry to key s

Definition at line 66 of file htable.cc.

67{
69 h=h%t->max;
70 telem p=t->t[h];
71 while(p!=NULL)
72 {
73 if (strcmp(s,p->key)==0) return p;
74 p=p->next;
75 }
76 return NULL;
77}