Prusa Slicer 2.6.0
Loading...
Searching...
No Matches
dict.c File Reference
#include <stddef.h>
#include "dict-list.h"
#include "memalloc.h"
+ Include dependency graph for dict.c:

Go to the source code of this file.

Functions

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

Function Documentation

◆ dictDelete()

void dictDelete ( Dict dict,
DictNode node 
)
95{
96 node->next->prev = node->prev;
97 node->prev->next = node->next;
98 memFree( node );
99}
DictNode * prev
Definition dict-list.h:91
DictNode * next
Definition dict-list.h:90
#define memFree
Definition memalloc.h:41

References memFree, DictNode::next, and DictNode::prev.

◆ dictDeleteDict()

void dictDeleteDict ( Dict dict)
62{
63 DictNode *node, *next;
64
65 for( node = dict->head.next; node != &dict->head; node = next ) {
66 next = node->next;
67 memFree( node );
68 }
69 memFree( dict );
70}
Definition dict-list.h:88
DictNode head
Definition dict-list.h:95

References Dict::head, memFree, and DictNode::next.

◆ dictInsertBefore()

DictNode * dictInsertBefore ( Dict dict,
DictNode node,
DictKey  key 
)
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}
DictKey key
Definition dict-list.h:89
#define memAlloc
Definition memalloc.h:48
int(* leq)(void *frame, DictKey key1, DictKey key2)
Definition dict-list.h:97
void * frame
Definition dict-list.h:96

References Dict::frame, DictNode::key, Dict::leq, memAlloc, DictNode::next, and DictNode::prev.

◆ dictNewDict()

Dict * dictNewDict ( void frame,
int(*)(void *frame, DictKey key1, DictKey key2)  leq 
)
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}
EIGEN_DEVICE_FUNC SegmentReturnType head(Index n)
This is the const version of head(Index).
Definition BlockMethods.h:919
Definition dict-list.h:94

References Dict::frame, head(), Dict::head, Dict::leq, and memAlloc.

+ Here is the call graph for this function:

◆ dictSearch()

DictNode * dictSearch ( Dict dict,
DictKey  key 
)
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}

References Dict::frame, Dict::head, DictNode::key, Dict::leq, and DictNode::next.