avlmel.h 2.3 KB

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