123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- /*!
- Temelia - Splay tree interface.
- Copyright (C) 2008, 2009 Ceata (http://cod.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.
- */
- #ifndef SPLAY_H_
- #define SPLAY_H_
- #include "platform.h"
- #include "binary_tree_common.h"
- struct _splay_tree_node;
- typedef struct _splay_tree_node *splay_tree_node;
- /*!
- * @see binary_tree_new
- */
- DECLSPEC splay_tree_t splay_tree_new(void *key);
- /*!
- * @see binary_tree_delete_node
- */
- DECLSPEC void splay_tree_delete_node(splay_tree_t splay);
- /*!
- * @see binary_tree_delete
- */
- DECLSPEC void splay_tree_delete(splay_tree_t splay);
- /*!
- * @see binary_tree_compare_trees
- */
- DECLSPEC int splay_tree_compare_trees(splay_tree_t splay1, splay_tree_t splay2,
- int compare(void *x, void *y, void *context), void *context);
- /*!
- * @see binary_tree_is_empty
- */
- DECLSPEC int splay_tree_is_empty(splay_tree_t splay);
- /*!
- * @see binary_tree_is_leaf
- */
- DECLSPEC int splay_tree_is_leaf(splay_tree_t splay);
- /*!
- * @see binary_tree_get_size
- * Complexity O(1)
- */
- DECLSPEC int splay_tree_get_size(splay_tree_t splay);
- /*!
- * @see binary_tree_get_root
- */
- DECLSPEC splay_tree_t splay_tree_get_root(splay_tree_t splay);
- /*!
- * @see binary_tree_get_key
- */
- DECLSPEC void *splay_tree_get_key(splay_tree_t splay);
- /*!
- * @see binary_tree_get_parent
- */
- DECLSPEC splay_tree_t splay_tree_get_parent(splay_tree_t splay);
- /*!
- * @see binary_tree_get_left_child
- */
- DECLSPEC splay_tree_t splay_tree_get_left_child(splay_tree_t splay);
- /*!
- * @see binary_tree_get_right_child
- */
- DECLSPEC splay_tree_t splay_tree_get_right_child(splay_tree_t splay);
- /*!
- * @see binary_tree_get_height
- */
- DECLSPEC int splay_tree_get_height(splay_tree_t splay);
- /*!
- * @see binary_tree_get_depth
- */
- DECLSPEC int splay_tree_get_depth(splay_tree_t splay);
- /*!
- * @see binary_search_tree_search
- */
- DECLSPEC splay_tree_t splay_tree_search(splay_tree_t splay, void *key, int compare(
- void *x, void *y, void *context), void *context);
- /*!
- * @see binary_search_tree_insert
- * @return New splay tree's root
- */
- DECLSPEC splay_tree_t splay_tree_insert(splay_tree_t splay, void *key, int compare(
- void *x, void *y, void *context), void *context);
- /*!
- * @see binary_search_tree_remove
- * @return The new splay tree's root
- */
- DECLSPEC splay_tree_t splay_tree_remove(splay_tree_t _splay_tree, void *key,
- int compare(void *x, void *y, void *context), void *context);
- /*!
- * @see binary_search_tree_get_min
- */
- DECLSPEC splay_tree_t splay_tree_get_min(splay_tree_t splay);
- /*!
- * @see binary_search_tree_get_max
- */
- DECLSPEC splay_tree_t splay_tree_get_max(splay_tree_t splay);
- /*!
- * @see binary_tree_preorder
- */
- DECLSPEC void splay_tree_preorder(splay_tree_t splay, void key_handler(void *x,
- void *context), void *context);
- /*!
- * @see binary_tree_inorder
- */
- DECLSPEC void splay_tree_inorder(splay_tree_t splay, void key_handler(void *x,
- void *context), void *context);
- /*!
- * @see binary_tree_reverse_inorder
- */
- DECLSPEC void splay_tree_reverse_inorder(splay_tree_t splay, void key_handler(void *x,
- void *context), void *context);
- /*!
- * @see binary_tree_postorder
- */
- DECLSPEC void splay_tree_postorder(splay_tree_t splay, void key_handler(void *x,
- void *context), void *context);
- /*!
- * @see binary_tree_level_order
- */
- DECLSPEC void splay_tree_level_order(splay_tree_t splay, void key_handler(void *x,
- void *context), void *context);
- /*!
- * @see binary_tree_show_indented
- */
- DECLSPEC void splay_tree_show_indented(splay_tree_t splay, void key_handler(void *x,
- int level, void *context), void *context);
- #endif /* SPLAY_H_ */
|