avlimap.h 2.2 KB

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