58 elog(
ERROR,
"red-black tree combines %d into %d",
110 for (
i = 1;
i < size;
i++)
135 for (
i = 0;
i < size;
i++)
140 elog(
ERROR,
"unexpected !isNew result from rbt_insert");
152 elog(
ERROR,
"unexpected isNew result from rbt_insert");
175 elog(
ERROR,
"left-right walk over empty tree produced an element");
187 elog(
ERROR,
"left-right walk gives elements not in sorted order");
193 elog(
ERROR,
"left-right walk did not reach end");
195 elog(
ERROR,
"left-right walk missed some elements");
215 elog(
ERROR,
"right-left walk over empty tree produced an element");
227 elog(
ERROR,
"right-left walk gives elements not in sorted order");
233 elog(
ERROR,
"right-left walk did not reach end");
235 elog(
ERROR,
"right-left walk missed some elements");
252 for (
i = 0;
i < size;
i++)
260 elog(
ERROR,
"inserted element was not found");
262 elog(
ERROR,
"find operation in rbtree gave wrong result");
269 for (
i = -1;
i <= 2 * size;
i += 2)
277 elog(
ERROR,
"not-inserted element was found");
313 elog(
ERROR,
"rbt_find_less() didn't find the equal key");
316 elog(
ERROR,
"rbt_find_great() didn't find the equal key");
319 elog(
ERROR,
"rbt_find_less() and rbt_find_great() found different equal keys");
334 elog(
ERROR,
"rbt_find_less() didn't find a lesser key");
355 elog(
ERROR,
"rbt_find_great() didn't find a greater key");
367 elog(
ERROR,
"rbt_find_less() found non-inserted element");
371 elog(
ERROR,
"rbt_find_less() found non-inserted element");
375 elog(
ERROR,
"rbt_find_great() found non-inserted element");
379 elog(
ERROR,
"rbt_find_great() found non-inserted element");
394 elog(
ERROR,
"leftmost node of empty tree is not NULL");
401 if (result ==
NULL || result->
key != 0)
402 elog(
ERROR,
"rbt_leftmost gave wrong result");
421 chosen = (
bool *)
palloc0(size *
sizeof(
bool));
443 elog(
ERROR,
"expected element was not found during deleting");
449 for (
i = 0;
i < size;
i++)
460 elog(
ERROR,
"deleted element still present in the rbtree");
465 if (result ==
NULL || result->
key !=
i)
466 elog(
ERROR,
"delete operation removed wrong rbtree value");
471 for (
i = 0;
i < size;
i++)
482 elog(
ERROR,
"expected element was not found during deleting");
489 elog(
ERROR,
"deleting all elements failed");
508 elog(
ERROR,
"invalid size for test_rb_tree: %d", size);
#define PG_FUNCTION_INFO_V1(funcname)
#define PG_GETARG_INT32(n)
void pfree(void *pointer)
void * palloc0(Size size)
uint64 pg_prng_uint64_range(pg_prng_state *state, uint64 rmin, uint64 rmax)
pg_prng_state pg_global_prng_state
RBTNode * rbt_find_great(RBTree *rbt, const RBTNode *data, bool equal_match)
RBTNode * rbt_iterate(RBTreeIterator *iter)
RBTNode * rbt_insert(RBTree *rbt, const RBTNode *data, bool *isNew)
void rbt_begin_iterate(RBTree *rbt, RBTOrderControl ctrl, RBTreeIterator *iter)
RBTNode * rbt_find_less(RBTree *rbt, const RBTNode *data, bool equal_match)
RBTree * rbt_create(Size node_size, rbt_comparator comparator, rbt_combiner combiner, rbt_allocfunc allocfunc, rbt_freefunc freefunc, void *arg)
RBTNode * rbt_find(RBTree *rbt, const RBTNode *data)
RBTNode * rbt_leftmost(RBTree *rbt)
void rbt_delete(RBTree *rbt, RBTNode *node)
static int find(struct vars *v, struct cnfa *cnfa, struct colormap *cm)
static int * GetPermutation(int size)
static RBTNode * irbt_alloc(void *arg)
Datum test_rb_tree(PG_FUNCTION_ARGS)
static void irbt_free(RBTNode *node, void *arg)
static void testleftright(int size)
static void irbt_combine(RBTNode *existing, const RBTNode *newdata, void *arg)
static void rbt_populate(RBTree *tree, int size, int step)
static void testleftmost(int size)
static void testdelete(int size, int delsize)
static void testfindltgt(int size)
static int irbt_cmp(const RBTNode *a, const RBTNode *b, void *arg)
static RBTree * create_int_rbtree(void)
static void testrightleft(int size)
static void testfind(int size)