Go to the documentation of this file. 83 #ifndef _SPLAY_TREE_MACROS_ 84 #define _SPLAY_TREE_MACROS_ 120 #define GENERAL_SPLAY_TREE(type, root, key, lt_field, gt_field, left, right, lt, gt) \ 121 struct type dummy_node; \ 122 struct type *ltree_max, *rtree_min, *yy; \ 123 if ((root) != NULL) { \ 124 ltree_max = rtree_min = &dummy_node; \ 126 if (lt((key), (root)->lt_field)) { \ 127 if ((yy = (root)->left) == NULL) \ 129 if (lt((key), yy->lt_field)) { \ 130 (root)->left = yy->right; \ 131 yy->right = (root); \ 133 if ((yy = (root)->left) == NULL) \ 136 rtree_min->left = (root); \ 137 rtree_min = (root); \ 138 } else if (gt((key), (root)->gt_field)) { \ 139 if ((yy = (root)->right) == NULL) \ 141 if (gt((key), yy->gt_field)) { \ 142 (root)->right = yy->left; \ 145 if ((yy = (root)->right) == NULL) \ 148 ltree_max->right = (root); \ 149 ltree_max = (root); \ 154 ltree_max->right = (root)->left; \ 155 rtree_min->left = (root)->right; \ 156 (root)->left = dummy_node.right; \ 157 (root)->right = dummy_node.left; \ 169 #define lcl_builtin_lt(a, b) ((a) < (b)) 170 #define lcl_builtin_gt(a, b) ((a) > (b)) 172 #define REGULAR_SPLAY_TREE(type, root, key, value, left, right) \ 173 GENERAL_SPLAY_TREE(type, root, key, value, value, left, right, lcl_builtin_lt, lcl_builtin_gt) 195 #define lcl_intvl_lt(a, b) ((a) < (b)) 196 #define lcl_intvl_gt(a, b) ((a) >= (b)) 198 #define INTERVAL_SPLAY_TREE(type, root, key, start, end, left, right) \ 199 GENERAL_SPLAY_TREE(type, root, key, start, end, left, right, lcl_intvl_lt, lcl_intvl_gt)