Lines Matching refs:list
1 /* xf86drmSL.c -- Skip list support
30 * This file contains a straightforward skip list implementation.n
103 SkipListPtr list;
106 list = drmMalloc(sizeof(*list));
107 if (!list) return NULL;
108 list->magic = SL_LIST_MAGIC;
109 list->level = 0;
110 list->head = SLCreateEntry(SL_MAX_LEVEL, 0, NULL);
111 list->count = 0;
113 for (i = 0; i <= SL_MAX_LEVEL; i++) list->head->forward[i] = NULL;
115 return list;
120 SkipListPtr list = (SkipListPtr)l;
124 if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
126 for (entry = list->head; entry; entry = next) {
133 list->magic = SL_FREED_MAGIC;
134 drmFree(list);
140 SkipListPtr list = (SkipListPtr)l;
144 if (list->magic != SL_LIST_MAGIC) return NULL;
146 for (i = list->level, entry = list->head; i >= 0; i--) {
157 SkipListPtr list = (SkipListPtr)l;
163 if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
165 entry = SLLocate(list, key, update);
167 if (entry && entry->key == key) return 1; /* Already in list */
171 if (level > list->level) {
172 level = ++list->level;
173 update[level] = list->head;
184 ++list->count;
190 SkipListPtr list = (SkipListPtr)l;
195 if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
197 entry = SLLocate(list, key, update);
202 for (i = 0; i <= list->level; i++) {
210 while (list->level && !list->head->forward[list->level]) --list->level;
211 --list->count;
217 SkipListPtr list = (SkipListPtr)l;
221 entry = SLLocate(list, key, update);
235 SkipListPtr list = (SkipListPtr)l;
239 SLLocate(list, key, update);
259 SkipListPtr list = (SkipListPtr)l;
262 if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
264 entry = list->p0;
267 list->p0 = entry->forward[0];
272 list->p0 = NULL;
278 SkipListPtr list = (SkipListPtr)l;
280 if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
282 list->p0 = list->head->forward[0];
283 return drmSLNext(list, key, value);
289 SkipListPtr list = (SkipListPtr)l;
293 if (list->magic != SL_LIST_MAGIC) {
295 list->magic, SL_LIST_MAGIC);
299 printf("Level = %d, count = %d\n", list->level, list->count);
300 for (entry = list->head; entry; entry = entry->forward[0]) {
303 list->magic, SL_ENTRY_MAGIC);