Graphviz 12.0.1~dev.20240716.0800
Loading...
Searching...
No Matches
red_black_tree.h
Go to the documentation of this file.
1/**********************************************************
2* See the LICENSE file for copyright infomation. *
3**********************************************************/
4
5#pragma once
6
7#ifdef __cplusplus
8extern "C" {
9#endif
10
11/* CONVENTIONS: All data structures for red-black trees have the prefix */
12/* "rb_" to prevent name conflicts. */
13/* */
14/* Function names: Each word in a function name begins with */
15/* a capital letter. An example funcntion name is */
16/* CreateRedTree(a,b,c). Furthermore, each function name */
17/* should begin with a capital letter to easily distinguish */
18/* them from variables. */
19/* */
20/* Variable names: Each word in a variable name begins with */
21/* a capital letter EXCEPT the first letter of the variable */
22/* name. For example, int newLongInt. Global variables have */
23/* names beginning with "g". An example of a global */
24/* variable name is gNewtonsConstant. */
25
26typedef struct rb_red_blk_node {
27 void* key;
28 int red; /* if red=0 then the node is black */
33
34
35/* Compare(a,b) should return 1 if *a > *b, -1 if *a < *b, and 0 otherwise */
36/* Destroy(a) takes a pointer to whatever key might be and frees it accordingly */
37typedef struct rb_red_blk_tree {
38 int (*Compare)(const void* a, const void* b);
39 void (*DestroyKey)(void* a);
40 /* A sentinel is used for root and for nil. These sentinels are */
41 /* created when RBTreeCreate is caled. root->left should always */
42 /* point to the node which is the root of the tree. nil points to a */
43 /* node which should always be black but has aribtrary children and */
44 /* parent and no key. The point of using these sentinels is so */
45 /* that the root and nil nodes do not require special cases in the code */
49
50rb_red_blk_tree* RBTreeCreate(int (*CompFunc)(const void*, const void*),
51 void (*DestFunc)(void *));
58
59#ifdef __cplusplus
60}
61#endif
disc key
Definition exparse.y:214
rb_red_blk_node * TreePredecessor(rb_red_blk_tree *, rb_red_blk_node *)
rb_red_blk_node * RBExactQuery(rb_red_blk_tree *, void *)
rb_red_blk_node * TreeSuccessor(rb_red_blk_tree *, rb_red_blk_node *)
rb_red_blk_node * RBTreeInsert(rb_red_blk_tree *, void *key)
void RBDelete(rb_red_blk_tree *, rb_red_blk_node *)
rb_red_blk_tree * RBTreeCreate(int(*CompFunc)(const void *, const void *), void(*DestFunc)(void *))
void RBTreeDestroy(rb_red_blk_tree *)
struct rb_red_blk_node * right
struct rb_red_blk_node * parent
struct rb_red_blk_node * left
rb_red_blk_node * nil
int(* Compare)(const void *a, const void *b)
rb_red_blk_node * root
void(* DestroyKey)(void *a)