kzc_binary_tree_node_manager.hpp File Reference

Node manager for binary tree. More...

Classes

struct  KzcBinaryTreeNode
 Structure of a BinaryTreeNode. More...
 

Typedefs

typedef void(* KzcNodeSwapFunction) (struct KzcBinaryTreeNode *first, struct KzcBinaryTreeNode *second)
 Swaps the content of the two nodes. More...
 

Functions

kzsError kzcBinaryTreeCreateManaged (const struct KzcMemoryManager *manager, KzcComparatorFunction comparator, KzcNodeSwapFunction swapHandler, struct KzcBinaryTree **out_binaryTree)
 Creates a new initially empty binary tree with given node management functions. More...
 
kzsError kzcBinaryTreeDeleteManaged (struct KzcBinaryTree *binaryTree)
 Deletes a binary tree without removing the nodes in it. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeGetRoot (const struct KzcBinaryTree *binaryTree)
 Gets the root node of the tree. More...
 
void kzcBinaryTreeSetRoot (struct KzcBinaryTree *binaryTree, struct KzcBinaryTreeNode *node)
 Sets the root node of the tree. More...
 
kzsError kzcBinaryTreeAddNode (struct KzcBinaryTree *binaryTree, struct KzcBinaryTreeNode *node)
 Adds the specified node to the binary tree. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeRemoveNode (struct KzcBinaryTree *binaryTree, struct KzcBinaryTreeNode *node)
 Removes the specified node from the binary tree. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeGetFirstNode (const struct KzcBinaryTree *binaryTree)
 Returns the first node in the tree. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeGetLastNode (const struct KzcBinaryTree *binaryTree)
 Returns the last node in the tree. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeGetEqualNode (const struct KzcBinaryTree *binaryTree, const void *element)
 Gets the node with equal value with the given one according to the ordering of the tree. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeGetLowerNode (const struct KzcBinaryTree *binaryTree, const void *element)
 Gets the node with the highest element lower than the given one according to the ordering of the tree. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeGetLowerOrEqualNode (const struct KzcBinaryTree *binaryTree, const void *element)
 Gets the node with the highest element lower or equal than the given one according to the ordering of the tree. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeGetHigherNode (const struct KzcBinaryTree *binaryTree, const void *element)
 Gets the node with the lowest element higher than the given one according to the ordering of the tree. More...
 
struct KzcBinaryTreeNodekzcBinaryTreeGetHigherOrEqualNode (const struct KzcBinaryTree *binaryTree, const void *element)
 Gets the node with the lowest element higher or equal than the given one according to the ordering of the tree. More...
 

Detailed Description

Node manager for binary tree.

This file provides possibility to create binary tree with more control on the internal node handling.

Copyright 2008-2017 by Rightware. All rights reserved.

Typedef Documentation

typedef void(* KzcNodeSwapFunction) (struct KzcBinaryTreeNode *first, struct KzcBinaryTreeNode *second)

Swaps the content of the two nodes.

Function Documentation

kzsError kzcBinaryTreeCreateManaged ( const struct KzcMemoryManager manager,
KzcComparatorFunction  comparator,
KzcNodeSwapFunction  swapHandler,
struct KzcBinaryTree **  out_binaryTree 
)

Creates a new initially empty binary tree with given node management functions.

kzsError kzcBinaryTreeDeleteManaged ( struct KzcBinaryTree binaryTree)

Deletes a binary tree without removing the nodes in it.

struct KzcBinaryTreeNode* kzcBinaryTreeGetRoot ( const struct KzcBinaryTree binaryTree)

Gets the root node of the tree.

void kzcBinaryTreeSetRoot ( struct KzcBinaryTree binaryTree,
struct KzcBinaryTreeNode node 
)

Sets the root node of the tree.

kzsError kzcBinaryTreeAddNode ( struct KzcBinaryTree binaryTree,
struct KzcBinaryTreeNode node 
)

Adds the specified node to the binary tree.

struct KzcBinaryTreeNode* kzcBinaryTreeRemoveNode ( struct KzcBinaryTree binaryTree,
struct KzcBinaryTreeNode node 
)

Removes the specified node from the binary tree.

To simplify the removal process, the removed node might not actually be the given one due to node swapping in the tree. The actual removed node is the return value.

struct KzcBinaryTreeNode* kzcBinaryTreeGetFirstNode ( const struct KzcBinaryTree binaryTree)

Returns the first node in the tree.

struct KzcBinaryTreeNode* kzcBinaryTreeGetLastNode ( const struct KzcBinaryTree binaryTree)

Returns the last node in the tree.

struct KzcBinaryTreeNode* kzcBinaryTreeGetEqualNode ( const struct KzcBinaryTree binaryTree,
const void *  element 
)

Gets the node with equal value with the given one according to the ordering of the tree.

struct KzcBinaryTreeNode* kzcBinaryTreeGetLowerNode ( const struct KzcBinaryTree binaryTree,
const void *  element 
)

Gets the node with the highest element lower than the given one according to the ordering of the tree.

struct KzcBinaryTreeNode* kzcBinaryTreeGetLowerOrEqualNode ( const struct KzcBinaryTree binaryTree,
const void *  element 
)

Gets the node with the highest element lower or equal than the given one according to the ordering of the tree.

struct KzcBinaryTreeNode* kzcBinaryTreeGetHigherNode ( const struct KzcBinaryTree binaryTree,
const void *  element 
)

Gets the node with the lowest element higher than the given one according to the ordering of the tree.

struct KzcBinaryTreeNode* kzcBinaryTreeGetHigherOrEqualNode ( const struct KzcBinaryTree binaryTree,
const void *  element 
)

Gets the node with the lowest element higher or equal than the given one according to the ordering of the tree.