avl_tree.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*
  2. * avl_tree.h
  3. *
  4. * Copyright (C) 2013 Aleksandar Andrejevic <theflash@sdf.lonestar.org>
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _AVL_TREE_H_
  20. #define _AVL_TREE_H_
  21. #include <common.h>
  22. typedef struct _avl_tree_t
  23. {
  24. struct _avl_tree_t *parent, *left, *right, *next_equal;
  25. qword_t key;
  26. } avl_tree_t;
  27. void avl_tree_insert(avl_tree_t **tree, avl_tree_t *node);
  28. avl_tree_t *avl_tree_lookup(avl_tree_t *tree, qword_t key);
  29. bool_t avl_tree_remove(avl_tree_t **tree, avl_tree_t *node);
  30. avl_tree_t *avl_tree_lower_bound(avl_tree_t *tree, qword_t key);
  31. avl_tree_t *avl_tree_upper_bound(avl_tree_t *tree, qword_t key);
  32. bool_t avl_tree_change_key(avl_tree_t **tree, avl_tree_t *node, qword_t new_key);
  33. avl_tree_t *avl_get_next_node(avl_tree_t *node);
  34. avl_tree_t *avl_get_previous_node(avl_tree_t *node);
  35. #endif