Implement RedBlacktree-Index.
RedBlacktree-Index impl | Implement RedBlacktree-Index. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file of RedBlacktree-Index. |
C-kern/ | Implementation file of RedBlacktree-Index impl. |
redblacktree_t | |
internal macros | |
COLOR | Returns the color bit of the node. |
ISBLACK | Returns true if color is black. |
ISRED | Returns true if color is red. |
PARENT | Access parent pointer from node. |
SETBLACK | Sets the color of node to black. |
SETRED | Sets the color of node to red. |
SETPARENT | Sets the new parent of node and keeps the encoded color. |
SETPARENTRED | Sets a new parent for node and sets its color to red. |
SETPARENTBLACK | Sets a new parent for node and sets its color to black. |
EVENADDRESS | Test for node having an even address (bit 0 is clear). |
KEYCOMPARE | Casts node to type typeadapt_object_t and calls callcmpkeyobj_typeadapt. |
NODECOMPARE | Casts both nodes to type typeadapt_object_t and calls callcmpobj_typeadapt. |
test | |
lifetime | |
search | |
change | |
iterate | |
Functions | |
test |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2011 Jörg Seebohn
Header file of RedBlacktree-Index.
Implementation file of RedBlacktree-Index impl.
internal macros | |
COLOR | Returns the color bit of the node. |
ISBLACK | Returns true if color is black. |
ISRED | Returns true if color is red. |
PARENT | Access parent pointer from node. |
SETBLACK | Sets the color of node to black. |
SETRED | Sets the color of node to red. |
SETPARENT | Sets the new parent of node and keeps the encoded color. |
SETPARENTRED | Sets a new parent for node and sets its color to red. |
SETPARENTBLACK | Sets a new parent for node and sets its color to black. |
EVENADDRESS | Test for node having an even address (bit 0 is clear). |
KEYCOMPARE | Casts node to type typeadapt_object_t and calls callcmpkeyobj_typeadapt. |
NODECOMPARE | Casts both nodes to type typeadapt_object_t and calls callcmpobj_typeadapt. |
test | |
lifetime | |
search | |
change | |
iterate |
#define KEYCOMPARE( key, node ) callcmpkeyobj_typeadaptmember(&tree->nodeadp, key, memberasobject_typeadaptmember(&tree->nodeadp, node))
Casts node to type typeadapt_object_t and calls callcmpkeyobj_typeadapt. This macro expects variable name tree to point to redblacktree_t.
#define NODECOMPARE( lnode, rnode ) callcmpobj_typeadaptmember(&tree->nodeadp, memberasobject_typeadaptmember(&tree->nodeadp, lnode), memberasobject_typeadaptmember(&tree->nodeadp, rnode))
Casts both nodes to type typeadapt_object_t and calls callcmpobj_typeadapt. This macro expects variable name tree to point to redblacktree_t.
Returns the color bit of the node.
#define COLOR( node ) (((uintptr_t)1) & (uintptr_t)((node)->parent))
Returns true if color is black.
#define ISBLACK( node ) (0 != COLOR(node))
Returns true if color is red.
#define ISRED( node ) (0 == COLOR(node))
Access parent pointer from node.
#define PARENT( node ) ((redblacktree_node_t*) (((uintptr_t)-2) & (uintptr_t)((node)->parent)))
Sets the color of node to black.
#define SETBLACK( node ) (node)->parent = (redblacktree_node_t*) (((uintptr_t)1) | (uintptr_t)((node)->parent))
Sets the color of node to red.
#define SETRED( node ) (node)->parent = PARENT(node)
Sets the new parent of node and keeps the encoded color.
#define SETPARENT( node, newparent ) (node)->parent = (redblacktree_node_t*) (COLOR(node) | (uintptr_t)newparent)
Sets a new parent for node and sets its color to red.
#define SETPARENTRED( node, newparent ) (node)->parent = newparent
Sets a new parent for node and sets its color to black.
#define SETPARENTBLACK( node, newparent ) (node)->parent = (redblacktree_node_t*) (((uintptr_t)1) | (uintptr_t)newparent)
Test for node having an even address (bit 0 is clear).
#define EVENADDRESS( node ) ((1u & (uintptr_t)(node)) == 0)
Casts node to type typeadapt_object_t and calls callcmpkeyobj_typeadapt.
#define KEYCOMPARE( key, node ) callcmpkeyobj_typeadaptmember(&tree->nodeadp, key, memberasobject_typeadaptmember(&tree->nodeadp, node))
Declares abstract object type.
typedef struct typeadapt_object_t typeadapt_object_t
Implements typeadapt_t.callcmpkeyobj_typeadapt.
#define callcmpkeyobj_typeadapt( typeadp, ... ) callcmpkeyobj_typeadaptcomparator(&(typeadp)->comparator, typeadp, __VA_ARGS__)
Casts both nodes to type typeadapt_object_t and calls callcmpobj_typeadapt.
#define NODECOMPARE( lnode, rnode ) callcmpobj_typeadaptmember(&tree->nodeadp, memberasobject_typeadaptmember(&tree->nodeadp, lnode), memberasobject_typeadaptmember(&tree->nodeadp, rnode))
Implements typeadapt_t.callcmpobj_typeadapt.
#define callcmpobj_typeadapt( typeadp, ... ) callcmpobj_typeadaptcomparator(&(typeadp)->comparator, typeadp, __VA_ARGS__)