avlimel.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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_AVLIMEL_H
  21. #define _AAPL_AVLIMEL_H
  22. #include "compare.h"
  23. #include "dlistmel.h"
  24. /**
  25. * \addtogroup avlitree
  26. * @{
  27. */
  28. /**
  29. * \class AvliMel
  30. * \brief Linked AVL tree for element appearing in multiple trees.
  31. *
  32. * AvliMel allows for an element to simultaneously be in multiple trees without
  33. * the trees interferring with one another. For each tree that the element is
  34. * to appear in, there must be a distinct set of AVL Tree management data that
  35. * can be unambiguously referenced with some base class name. This name
  36. * is passed to the tree as a template parameter and is used in the tree
  37. * algorithms.
  38. *
  39. * The element must use the same key type and value in each tree that it
  40. * appears in. If distinct keys are required, the AvliMelKey structure is
  41. * available.
  42. *
  43. * AvliMel does not assume ownership of elements in the tree. The destructor
  44. * will not delete the elements. If the user wishes to explicitly deallocate
  45. * all the items in the tree the empty() routine is available.
  46. *
  47. * \include ex_avlimel.cpp
  48. */
  49. /*@}*/
  50. #define BASE_EL(name) BaseEl::name
  51. #define BASEKEY(name) name
  52. #define BASELIST DListMel< Element, BaseEl >
  53. #define AVLMEL_CLASSDEF class Element, class Key, \
  54. class BaseEl, class Compare = CmpOrd<Key>
  55. #define AVLMEL_TEMPDEF class Element, class Key, \
  56. class BaseEl, class Compare
  57. #define AVLMEL_TEMPUSE Element, Key, BaseEl, Compare
  58. #define AvlTree AvliMel
  59. #define WALKABLE
  60. #include "avlcommon.h"
  61. #undef BASE_EL
  62. #undef BASEKEY
  63. #undef BASELIST
  64. #undef AVLMEL_CLASSDEF
  65. #undef AVLMEL_TEMPDEF
  66. #undef AVLMEL_TEMPUSE
  67. #undef AvlTree
  68. #undef WALKABLE
  69. #endif /* _AAPL_AVLIMEL_H */