avlitree.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2002 Adrian Thurston <thurston@cs.queensu.ca>
  3. */
  4. /* This file is part of Aapl.
  5. *
  6. * Aapl is free software; you can redistribute it and/or modify it under the
  7. * terms of the GNU Lesser General Public License as published by the Free
  8. * Software Foundation; either version 2.1 of the License, or (at your option)
  9. * any later version.
  10. *
  11. * Aapl is distributed in the hope that it will be useful, but WITHOUT ANY
  12. * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with Aapl; if not, write to the Free Software Foundation, Inc., 59
  18. * Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #ifndef _AAPL_AVLITREE_H
  21. #define _AAPL_AVLITREE_H
  22. #include "compare.h"
  23. #include "dlistmel.h"
  24. /**
  25. * \addtogroup avlitree
  26. * @{
  27. */
  28. /**
  29. * \class AvliTree
  30. * \brief Linked AVL tree.
  31. *
  32. * AvliTree is the standard linked by-structure AVL tree. To use this
  33. * structure the user must define an element type and give it the necessary
  34. * properties. At the very least it must have a getKey() function that will be
  35. * used to compare the relative ordering of elements and tree management data
  36. * necessary for the AVL algorithm. An element type can acquire the management
  37. * data by inheriting the AvliTreeEl class.
  38. *
  39. * AvliTree does not presume to manage the allocation of elements in the tree.
  40. * The destructor will not delete the items in the tree, instead the elements
  41. * must be explicitly de-allocated by the user if necessary and when it is
  42. * safe to do so. The empty() routine will traverse the tree and delete all
  43. * items.
  44. *
  45. * Since the tree does not manage the elements, it can contain elements that
  46. * are allocated statically or that are part of another data structure.
  47. *
  48. * \include ex_avlitree.cpp
  49. */
  50. /*@}*/
  51. #define BASE_EL(name) name
  52. #define BASEKEY(name) name
  53. #define BASELIST DListMel< Element, AvliTreeEl<Element> >
  54. #define AVLMEL_CLASSDEF class Element, class Key, class Compare = CmpOrd<Key>
  55. #define AVLMEL_TEMPDEF class Element, class Key, class Compare
  56. #define AVLMEL_TEMPUSE Element, Key, Compare
  57. #define AvlTree AvliTree
  58. #define WALKABLE
  59. #include "avlcommon.h"
  60. #undef BASE_EL
  61. #undef BASEKEY
  62. #undef BASELIST
  63. #undef AVLMEL_CLASSDEF
  64. #undef AVLMEL_TEMPDEF
  65. #undef AVLMEL_TEMPUSE
  66. #undef AvlTree
  67. #undef WALKABLE
  68. #endif /* _AAPL_AVLITREE_H */