Node manager for binary tree. More...
#include <kanzi/core/legacy/util/collection/kzc_comparator.hpp>
#include <kanzi/core/legacy/debug/kzs_error.hpp>
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 KzcBinaryTreeNode * | kzcBinaryTreeGetRoot (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 KzcBinaryTreeNode * | kzcBinaryTreeRemoveNode (struct KzcBinaryTree *binaryTree, struct KzcBinaryTreeNode *node) |
Removes the specified node from the binary tree. More... | |
struct KzcBinaryTreeNode * | kzcBinaryTreeGetFirstNode (const struct KzcBinaryTree *binaryTree) |
Returns the first node in the tree. More... | |
struct KzcBinaryTreeNode * | kzcBinaryTreeGetLastNode (const struct KzcBinaryTree *binaryTree) |
Returns the last node in the tree. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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 void(* KzcNodeSwapFunction) (struct KzcBinaryTreeNode *first, struct KzcBinaryTreeNode *second) |
Swaps the content of the two nodes.
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.