• Home
  • Raw
  • Download

Lines Matching refs:elm

82 #define SPLAY_LEFT(elm, field)		(elm)->field.spe_left  argument
83 #define SPLAY_RIGHT(elm, field) (elm)->field.spe_right argument
129 name##_SPLAY_FIND(struct name *head, struct type *elm) \
133 name##_SPLAY(head, elm); \
134 if ((cmp)(elm, (head)->sph_root) == 0) \
140 name##_SPLAY_NEXT(struct name *head, struct type *elm) \
142 name##_SPLAY(head, elm); \
143 if (SPLAY_RIGHT(elm, field) != NULL) { \
144 elm = SPLAY_RIGHT(elm, field); \
145 while (SPLAY_LEFT(elm, field) != NULL) { \
146 elm = SPLAY_LEFT(elm, field); \
149 elm = NULL; \
150 return (elm); \
165 name##_SPLAY_INSERT(struct name *head, struct type *elm) \
168 SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \
171 name##_SPLAY(head, elm); \
172 __comp = (cmp)(elm, (head)->sph_root); \
174 SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
175 SPLAY_RIGHT(elm, field) = (head)->sph_root; \
178 SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
179 SPLAY_LEFT(elm, field) = (head)->sph_root; \
184 (head)->sph_root = (elm); \
189 name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
194 name##_SPLAY(head, elm); \
195 if ((cmp)(elm, (head)->sph_root) == 0) { \
201 name##_SPLAY(head, elm); \
204 return (elm); \
210 name##_SPLAY(struct name *head, struct type *elm) \
218 while ((__comp = (cmp)(elm, (head)->sph_root))) { \
223 if ((cmp)(elm, __tmp) < 0){ \
233 if ((cmp)(elm, __tmp) > 0){ \
320 #define RB_LEFT(elm, field) (elm)->field.rbe_left argument
321 #define RB_RIGHT(elm, field) (elm)->field.rbe_right argument
322 #define RB_PARENT(elm, field) (elm)->field.rbe_parent argument
323 #define RB_COLOR(elm, field) (elm)->field.rbe_color argument
327 #define RB_SET(elm, parent, field) do { \ argument
328 RB_PARENT(elm, field) = parent; \
329 RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \
330 RB_COLOR(elm, field) = RB_RED; \
342 #define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ argument
343 (tmp) = RB_RIGHT(elm, field); \
344 if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field))) { \
345 RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \
347 RB_AUGMENT(elm); \
348 if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \
349 if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
350 RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
352 RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
355 RB_LEFT(tmp, field) = (elm); \
356 RB_PARENT(elm, field) = (tmp); \
362 #define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ argument
363 (tmp) = RB_LEFT(elm, field); \
364 if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field))) { \
365 RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \
367 RB_AUGMENT(elm); \
368 if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field))) { \
369 if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \
370 RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \
372 RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \
375 RB_RIGHT(tmp, field) = (elm); \
376 RB_PARENT(elm, field) = (tmp); \
408 name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \
411 while ((parent = RB_PARENT(elm, field)) && \
419 elm = gparent; \
422 if (RB_RIGHT(parent, field) == elm) { \
425 parent = elm; \
426 elm = tmp; \
435 elm = gparent; \
438 if (RB_LEFT(parent, field) == elm) { \
441 parent = elm; \
442 elm = tmp; \
452 name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, struct type *elm) \
455 while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \
456 elm != RB_ROOT(head)) { \
457 if (RB_LEFT(parent, field) == elm) { \
469 elm = parent; \
470 parent = RB_PARENT(elm, field); \
486 elm = RB_ROOT(head); \
501 elm = parent; \
502 parent = RB_PARENT(elm, field); \
518 elm = RB_ROOT(head); \
523 if (elm) \
524 RB_COLOR(elm, field) = RB_BLACK; \
528 name##_RB_REMOVE(struct name *head, struct type *elm) \
530 struct type *child, *parent, *old = elm; \
532 if (RB_LEFT(elm, field) == NULL) \
533 child = RB_RIGHT(elm, field); \
534 else if (RB_RIGHT(elm, field) == NULL) \
535 child = RB_LEFT(elm, field); \
538 elm = RB_RIGHT(elm, field); \
539 while ((left = RB_LEFT(elm, field))) \
540 elm = left; \
541 child = RB_RIGHT(elm, field); \
542 parent = RB_PARENT(elm, field); \
543 color = RB_COLOR(elm, field); \
547 if (RB_LEFT(parent, field) == elm) \
554 if (RB_PARENT(elm, field) == old) \
555 parent = elm; \
556 (elm)->field = (old)->field; \
559 RB_LEFT(RB_PARENT(old, field), field) = elm;\
561 RB_RIGHT(RB_PARENT(old, field), field) = elm;\
564 RB_ROOT(head) = elm; \
565 RB_PARENT(RB_LEFT(old, field), field) = elm; \
567 RB_PARENT(RB_RIGHT(old, field), field) = elm; \
576 parent = RB_PARENT(elm, field); \
577 color = RB_COLOR(elm, field); \
581 if (RB_LEFT(parent, field) == elm) \
596 name##_RB_INSERT(struct name *head, struct type *elm) \
604 comp = (cmp)(elm, parent); \
612 RB_SET(elm, parent, field); \
615 RB_LEFT(parent, field) = elm; \
617 RB_RIGHT(parent, field) = elm; \
620 RB_ROOT(head) = elm; \
621 name##_RB_INSERT_COLOR(head, elm); \
627 name##_RB_FIND(struct name *head, struct type *elm) \
632 comp = cmp(elm, tmp); \
645 name##_RB_NFIND(struct name *head, struct type *elm) \
651 comp = cmp(elm, tmp); \
666 name##_RB_NEXT(struct type *elm) \
668 if (RB_RIGHT(elm, field)) { \
669 elm = RB_RIGHT(elm, field); \
670 while (RB_LEFT(elm, field)) \
671 elm = RB_LEFT(elm, field); \
673 if (RB_PARENT(elm, field) && \
674 (elm == RB_LEFT(RB_PARENT(elm, field), field))) \
675 elm = RB_PARENT(elm, field); \
677 while (RB_PARENT(elm, field) && \
678 (elm == RB_RIGHT(RB_PARENT(elm, field), field)))\
679 elm = RB_PARENT(elm, field); \
680 elm = RB_PARENT(elm, field); \
683 return (elm); \
688 name##_RB_PREV(struct type *elm) \
690 if (RB_LEFT(elm, field)) { \
691 elm = RB_LEFT(elm, field); \
692 while (RB_RIGHT(elm, field)) \
693 elm = RB_RIGHT(elm, field); \
695 if (RB_PARENT(elm, field) && \
696 (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \
697 elm = RB_PARENT(elm, field); \
699 while (RB_PARENT(elm, field) && \
700 (elm == RB_LEFT(RB_PARENT(elm, field), field)))\
701 elm = RB_PARENT(elm, field); \
702 elm = RB_PARENT(elm, field); \
705 return (elm); \