40Dict *dictNewDict(
void *frame,
41 int (*leq)(
void *frame, DictKey key1, DictKey key2) )
43 Dict *dict = (Dict *) memAlloc(
sizeof( Dict ));
46 if (dict == NULL)
return NULL;
61void dictDeleteDict( Dict *dict )
63 DictNode *node, *next;
65 for( node = dict->head.next; node != &dict->head; node = next ) {
73DictNode *dictInsertBefore( Dict *dict, DictNode *node, DictKey
key )
79 }
while( node->key != NULL && ! (*dict->leq)(dict->frame, node->key,
key));
81 newNode = (DictNode *) memAlloc(
sizeof( DictNode ));
82 if (newNode == NULL)
return NULL;
85 newNode->next = node->next;
86 node->next->prev = newNode;
94void dictDelete( Dict *dict, DictNode *node )
96 node->next->prev = node->prev;
97 node->prev->next = node->next;
102DictNode *dictSearch( Dict *dict, DictKey
key )
104 DictNode *node = &dict->head;
108 }
while( node->key != NULL && ! (*dict->leq)(dict->frame,
key, node->key));