avlmap.h 2.1 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_AVLMAP_H
  21. #define _AAPL_AVLMAP_H
  22. #include "compare.h"
  23. /**
  24. * \addtogroup avltree
  25. * @{
  26. */
  27. /**
  28. * \class AvlMap
  29. * \brief Key and value oriented AVL tree.
  30. *
  31. * AvlMap stores key and value pairs in elements that managed by the tree. It
  32. * is intendend to be similar to map template found in the STL. AvlMap
  33. * requires that a Key type, a Value type, and a class containing a compare()
  34. * routine for Key be given. Items can be inserted with just a key or with a
  35. * key and value pair.
  36. *
  37. * AvlMap assumes all elements in the tree are allocated on the heap and are
  38. * to be managed by the tree. This means that the class destructor will delete
  39. * the contents of the tree. A deep copy will cause existing elements to be
  40. * deleted first.
  41. *
  42. * \include ex_avlmap.cpp
  43. */
  44. /*@}*/
  45. #define AVLTREE_MAP
  46. #define BASE_EL(name) name
  47. #define BASEKEY(name) name
  48. #define AVLMEL_CLASSDEF class Key, class Value, class Compare = CmpOrd<Key>
  49. #define AVLMEL_TEMPDEF class Key, class Value, class Compare
  50. #define AVLMEL_TEMPUSE Key, Value, Compare
  51. #define AvlTree AvlMap
  52. #define Element AvlMapEl<Key,Value>
  53. #include "avlcommon.h"
  54. #undef AVLTREE_MAP
  55. #undef BASE_EL
  56. #undef BASEKEY
  57. #undef AVLMEL_CLASSDEF
  58. #undef AVLMEL_TEMPDEF
  59. #undef AVLMEL_TEMPUSE
  60. #undef AvlTree
  61. #undef Element
  62. #endif /* _AAPL_AVLMAP_H */