avlmelkey.h 2.3 KB

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