dlistmel.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Copyright 2001 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_DLISTMEL_H
  21. #define _AAPL_DLISTMEL_H
  22. /**
  23. * \addtogroup dlist
  24. * @{
  25. */
  26. /**
  27. * \class DListMel
  28. * \brief Doubly linked list for elements that may appear in multiple lists.
  29. *
  30. * This class is similar to DList, except that the user defined list element
  31. * can inherit from multple DListEl classes and consequently be an element in
  32. * multiple lists. In other words, DListMel allows a single instance of a data
  33. * structure to be an element in multiple lists without the lists interfereing
  34. * with one another.
  35. *
  36. * For each list that an element class is to appear in, the element must have
  37. * unique next and previous pointers that can be unambiguously refered to with
  38. * some base class name. This name is given to DListMel as a template argument
  39. * so it can use the correct next and previous pointers in its list
  40. * operations.
  41. *
  42. * DListMel does not assume ownership of elements in the list. If the elements
  43. * are known to reside on the heap and are not contained in any other list or
  44. * data structure, the provided empty() routine can be used to delete all
  45. * elements, however the destructor will not call this routine, it will simply
  46. * abandon all the elements. It is up to the programmer to explicitly
  47. * de-allocate items when it is safe to do so.
  48. *
  49. * \include ex_dlistmel.cpp
  50. */
  51. /*@}*/
  52. #define BASE_EL(name) BaseEl::name
  53. #define DLMEL_TEMPDEF class Element, class BaseEl
  54. #define DLMEL_TEMPUSE Element, BaseEl
  55. #define DList DListMel
  56. #include "dlcommon.h"
  57. #undef BASE_EL
  58. #undef DLMEL_TEMPDEF
  59. #undef DLMEL_TEMPUSE
  60. #undef DList
  61. #endif /* _AAPL_DLISTMEL_H */