40 Dict *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;
61 void dictDeleteDict( Dict *dict )
63 DictNode *node, *next;
65 for( node = dict->head.next; node != &dict->head; node = next ) {
73 DictNode *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;
94 void dictDelete( Dict *dict, DictNode *node )
97 node->next->prev = node->prev;
98 node->prev->next = node->next;
103 DictNode *dictSearch( Dict *dict, DictKey key )
105 DictNode *node = &dict->head;
109 }
while( node->key != NULL && ! (*dict->leq)(dict->frame, key, node->key));