123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- /*!
- Temelia - Binary search tree implementation source file.
- Copyright (C) 2008, 2009 Ceata (http://ceata.org/proiecte/temelia).
- @author Dascalu Laurentiu
- This program is free software; you can redistribute it and
- modify it under the terms of the GNU General Public License
- as published by the Free Software Foundation; either version 3
- 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.
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
- #include "include/binary_search_tree.h"
- /*!
- * All the functions are wrappers, one to one calls, over the private
- * functions from the binary_tree_common.h header.
- */
- binary_search_tree_t binary_search_tree_new(void *key)
- {
- return _binary_tree_new(key);
- }
- void binary_search_tree_delete_node(binary_search_tree_node_t node)
- {
- _binary_tree_delete_node(node);
- }
- void binary_search_tree_delete(binary_search_tree_t bst)
- {
- _binary_tree_delete(bst);
- }
- int binary_search_tree_empty(binary_search_tree_t bst)
- {
- return _binary_tree_is_empty(bst);
- }
- int binary_search_tree_leaf(binary_search_tree_t bst)
- {
- return _binary_tree_leaf(bst);
- }
- int binary_search_tree_get_size(binary_search_tree_t bst)
- {
- return _binary_tree_get_size(bst);
- }
- binary_search_tree_t binary_search_tree_get_root(binary_search_tree_node_t node)
- {
- return _binary_tree_get_root(node);
- }
- void *binary_search_tree_get_key(binary_search_tree_node_t node)
- {
- return _binary_tree_get_key(node);
- }
- binary_search_tree_node_t binary_search_tree_get_parent(
- binary_search_tree_node_t node)
- {
- return _binary_tree_get_parent(node);
- }
- binary_search_tree_node_t binary_search_tree_get_left_child(
- binary_search_tree_node_t node)
- {
- return _binary_tree_get_left_child(node);
- }
- binary_search_tree_node_t binary_search_tree_get_right_child(
- binary_search_tree_node_t node)
- {
- return _binary_tree_get_right_child(node);
- }
- void binary_search_tree_split(binary_search_tree_t parent,
- binary_search_tree_t *left, binary_search_tree_t *right)
- {
- _binary_tree_split(parent, left, right);
- }
- int binary_search_tree_get_height(binary_search_tree_t tree)
- {
- return _binary_tree_get_height(tree);
- }
- int binary_search_tree_get_depth(binary_search_tree_node_t node)
- {
- return _binary_tree_get_depth(node);
- }
- binary_search_tree_node_t binary_search_tree_search(binary_search_tree_t bst,
- void *key, int compare(void *x, void *y, void *context), void *context)
- {
- return _binary_search_tree_search(bst, key, compare, context);
- }
- binary_search_tree_node_t binary_search_tree_insert(binary_search_tree_t bst,
- void *key, int compare(void *x, void *y, void *context), void *context)
- {
- return _binary_search_tree_insert(bst, key, compare, context);
- }
- binary_search_tree_node_t binary_search_tree_remove(binary_search_tree_t *bst,
- void *key, int compare(void *x, void *y, void *context), void *context,
- binary_search_tree_t *freed)
- {
- return _binary_search_tree_remove(bst, key, compare, context, freed);
- }
- binary_search_tree_node_t binary_search_tree_get_min(binary_search_tree_t bst)
- {
- return _binary_search_tree_get_min(bst);
- }
- binary_search_tree_node_t binary_search_tree_get_max(binary_search_tree_t bst)
- {
- return _binary_search_tree_get_max(bst);
- }
- binary_search_tree_node_t binary_search_tree_next(binary_search_tree_t bst,
- binary_search_tree_node_t node)
- {
- return _binary_search_tree_next(bst, node);
- }
- binary_search_tree_node_t binary_search_tree_prev(binary_search_tree_t bst,
- binary_search_tree_node_t node)
- {
- return _binary_search_tree_prev(bst, node);
- }
- void binary_search_tree_preorder(binary_search_tree_t tree, void key_handler(
- void *x, void *context), void *context)
- {
- _binary_tree_preorder(tree, key_handler, context);
- }
- void binary_search_tree_inorder(binary_search_tree_t tree, void key_handler(
- void *x, void *context), void *context)
- {
- _binary_tree_inorder(tree, key_handler, context);
- }
- void binary_search_tree_reverse_inorder(binary_search_tree_t tree,
- void key_handler(void *x, void *context), void *context)
- {
- _binary_tree_reverse_inorder(tree, key_handler, context);
- }
- void binary_search_tree_postorder(binary_search_tree_t tree, void key_handler(
- void *x, void *context), void *context)
- {
- _binary_tree_postorder(tree, key_handler, context);
- }
- void binary_search_tree_level_order(binary_search_tree_t tree, void key_handler(
- void *x, void *context), void *context)
- {
- _binary_tree_level_order(tree, key_handler, context);
- }
- void binary_search_tree_show_indented(binary_search_tree_t tree,
- void key_handler(void *key, int level, void *context), void *context)
- {
- _binary_tree_show_indented(tree, key_handler, context, 0);
- }
|