ReactOS 0.4.15-dev-7674-gc0b4db1
dict.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  DictNode
 
struct  Dict
 

Macros

#define DictKey   DictListKey
 
#define Dict   DictList
 
#define DictNode   DictListNode
 
#define dictNewDict(frame, leq)   __gl_dictListNewDict(frame,leq)
 
#define dictDeleteDict(dict)   __gl_dictListDeleteDict(dict)
 
#define dictSearch(dict, key)   __gl_dictListSearch(dict,key)
 
#define dictInsert(dict, key)   __gl_dictListInsert(dict,key)
 
#define dictInsertBefore(dict, node, key)   __gl_dictListInsertBefore(dict,node,key)
 
#define dictDelete(dict, node)   __gl_dictListDelete(dict,node)
 
#define dictKey(n)   __gl_dictListKey(n)
 
#define dictSucc(n)   __gl_dictListSucc(n)
 
#define dictPred(n)   __gl_dictListPred(n)
 
#define dictMin(d)   __gl_dictListMin(d)
 
#define dictMax(d)   __gl_dictListMax(d)
 
#define __gl_dictListKey(n)   ((n)->key)
 
#define __gl_dictListSucc(n)   ((n)->next)
 
#define __gl_dictListPred(n)   ((n)->prev)
 
#define __gl_dictListMin(d)   ((d)->head.next)
 
#define __gl_dictListMax(d)   ((d)->head.prev)
 
#define __gl_dictListInsert(d, k)   (dictInsertBefore((d),&(d)->head,(k)))
 

Typedefs

typedef voidDictKey
 
typedef struct Dict Dict
 
typedef struct DictNode DictNode
 

Functions

DictdictNewDict (void *frame, int(*leq)(void *frame, DictKey key1, DictKey key2))
 
void dictDeleteDict (Dict *dict)
 
DictNodedictSearch (Dict *dict, DictKey key)
 
DictNodedictInsertBefore (Dict *dict, DictNode *node, DictKey key)
 
void dictDelete (Dict *dict, DictNode *node)
 

Macro Definition Documentation

◆ __gl_dictListInsert

#define __gl_dictListInsert (   d,
  k 
)    (dictInsertBefore((d),&(d)->head,(k)))

Definition at line 83 of file dict.h.

◆ __gl_dictListKey

#define __gl_dictListKey (   n)    ((n)->key)

Definition at line 78 of file dict.h.

◆ __gl_dictListMax

#define __gl_dictListMax (   d)    ((d)->head.prev)

Definition at line 82 of file dict.h.

◆ __gl_dictListMin

#define __gl_dictListMin (   d)    ((d)->head.next)

Definition at line 81 of file dict.h.

◆ __gl_dictListPred

#define __gl_dictListPred (   n)    ((n)->prev)

Definition at line 80 of file dict.h.

◆ __gl_dictListSucc

#define __gl_dictListSucc (   n)    ((n)->next)

Definition at line 79 of file dict.h.

◆ Dict

#define Dict   DictList

Definition at line 41 of file dict.h.

◆ dictDelete

#define dictDelete (   dict,
  node 
)    __gl_dictListDelete(dict,node)

Definition at line 50 of file dict.h.

◆ dictDeleteDict

#define dictDeleteDict (   dict)    __gl_dictListDeleteDict(dict)

Definition at line 45 of file dict.h.

◆ dictInsert

#define dictInsert (   dict,
  key 
)    __gl_dictListInsert(dict,key)

Definition at line 48 of file dict.h.

◆ dictInsertBefore

#define dictInsertBefore (   dict,
  node,
  key 
)    __gl_dictListInsertBefore(dict,node,key)

Definition at line 49 of file dict.h.

◆ DictKey

#define DictKey   DictListKey

Definition at line 40 of file dict.h.

◆ dictKey

#define dictKey (   n)    __gl_dictListKey(n)

Definition at line 52 of file dict.h.

◆ dictMax

#define dictMax (   d)    __gl_dictListMax(d)

Definition at line 56 of file dict.h.

◆ dictMin

#define dictMin (   d)    __gl_dictListMin(d)

Definition at line 55 of file dict.h.

◆ dictNewDict

#define dictNewDict (   frame,
  leq 
)    __gl_dictListNewDict(frame,leq)

Definition at line 44 of file dict.h.

◆ DictNode

#define DictNode   DictListNode

Definition at line 42 of file dict.h.

◆ dictPred

#define dictPred (   n)    __gl_dictListPred(n)

Definition at line 54 of file dict.h.

◆ dictSearch

#define dictSearch (   dict,
  key 
)    __gl_dictListSearch(dict,key)

Definition at line 47 of file dict.h.

◆ dictSucc

#define dictSucc (   n)    __gl_dictListSucc(n)

Definition at line 53 of file dict.h.

Typedef Documentation

◆ Dict

typedef struct Dict Dict

Definition at line 61 of file dict.h.

◆ DictKey

typedef void* DictKey

Definition at line 60 of file dict.h.

◆ DictNode

Definition at line 62 of file dict.h.

Function Documentation

◆ dictDelete()

void dictDelete ( Dict dict,
DictNode node 
)

Definition at line 94 of file dict.c.

95{
96 node->next->prev = node->prev;
97 node->prev->next = node->next;
98 memFree( node );
99}
#define memFree
Definition: memalloc.h:41
Definition: dlist.c:348
void * next
Definition: dlist.c:360

◆ dictDeleteDict()

void dictDeleteDict ( Dict dict)

Definition at line 61 of file dict.c.

62{
64
65 for( node = dict->head.next; node != &dict->head; node = next ) {
66 next = node->next;
67 memFree( node );
68 }
69 memFree( dict );
70}
static unsigned __int64 next
Definition: rand_nt.c:6
DictNode * next
Definition: dict-list.h:90
DictNode head
Definition: dict-list.h:95

◆ dictInsertBefore()

DictNode * dictInsertBefore ( Dict dict,
DictNode node,
DictKey  key 
)

Definition at line 73 of file dict.c.

74{
75 DictNode *newNode;
76
77 do {
78 node = node->prev;
79 } while( node->key != NULL && ! (*dict->leq)(dict->frame, node->key, key));
80
81 newNode = (DictNode *) memAlloc( sizeof( DictNode ));
82 if (newNode == NULL) return NULL;
83
84 newNode->key = key;
85 newNode->next = node->next;
86 node->next->prev = newNode;
87 newNode->prev = node;
88 node->next = newNode;
89
90 return newNode;
91}
#define NULL
Definition: types.h:112
#define memAlloc
Definition: memalloc.h:48
DictNode * prev
Definition: dict-list.h:91
DictKey key
Definition: dict-list.h:89
int(* leq)(void *frame, DictKey key1, DictKey key2)
Definition: dict-list.h:97
void * frame
Definition: dict-list.h:96
Definition: copy.c:22

◆ dictNewDict()

Dict * dictNewDict ( void frame,
int(*)(void *frame, DictKey key1, DictKey key2)  leq 
)

Definition at line 40 of file dict.c.

42{
43 Dict *dict = (Dict *) memAlloc( sizeof( Dict ));
45
46 if (dict == NULL) return NULL;
47
48 head = &dict->head;
49
50 head->key = NULL;
51 head->next = head;
52 head->prev = head;
53
54 dict->frame = frame;
55 dict->leq = leq;
56
57 return dict;
58}
struct outqueuenode * head
Definition: adnsresfilter.c:66
Definition: dict-list.h:94

◆ dictSearch()

DictNode * dictSearch ( Dict dict,
DictKey  key 
)

Definition at line 102 of file dict.c.

103{
104 DictNode *node = &dict->head;
105
106 do {
107 node = node->next;
108 } while( node->key != NULL && ! (*dict->leq)(dict->frame, key, node->key));
109
110 return node;
111}