avlimelkey.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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_AVLIMELKEY_H
  21. #define _AAPL_AVLIMELKEY_H
  22. #include "compare.h"
  23. #include "dlistmel.h"
  24. /**
  25. * \addtogroup avlitree
  26. * @{
  27. */
  28. /**
  29. * \class AvliMelKey
  30. * \brief Linked AVL tree for element appearing in multiple trees with different keys.
  31. *
  32. * AvliMelKey is similar to AvliMel, except that an additional template
  33. * parameter, BaseKey, is provided for resolving ambiguous references to
  34. * getKey(). This means that if an element is stored in multiple trees, each
  35. * tree can use a different key for ordering the elements in it. Using
  36. * AvliMelKey an array of data structures can be indexed with an O(log(n))
  37. * search on two or more of the values contained within it and without
  38. * allocating any additional data.
  39. *
  40. * AvliMelKey does not assume ownership of elements in the tree. The destructor
  41. * will not delete the elements. If the user wishes to explicitly deallocate
  42. * all the items in the tree the empty() routine is available.
  43. *
  44. * \include ex_avlimelkey.cpp
  45. */
  46. /*@}*/
  47. #define BASE_EL(name) BaseEl::name
  48. #define BASEKEY(name) BaseKey::name
  49. #define BASELIST DListMel< Element, BaseEl >
  50. #define AVLMEL_CLASSDEF class Element, class Key, class BaseEl, \
  51. class BaseKey, class Compare = CmpOrd<Key>
  52. #define AVLMEL_TEMPDEF class Element, class Key, class BaseEl, \
  53. class BaseKey, class Compare
  54. #define AVLMEL_TEMPUSE Element, Key, BaseEl, BaseKey, Compare
  55. #define AvlTree AvliMelKey
  56. #define WALKABLE
  57. #include "avlcommon.h"
  58. #undef BASE_EL
  59. #undef BASEKEY
  60. #undef BASELIST
  61. #undef AVLMEL_CLASSDEF
  62. #undef AVLMEL_TEMPDEF
  63. #undef AVLMEL_TEMPUSE
  64. #undef AvlTree
  65. #undef WALKABLE
  66. #endif /* _AAPL_AVLIMELKEY_H */