DoublyLinkedList.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #ifndef _DoublyLinkedList_h_
  2. #define _DoublyLinkedList_h_
  3. /* DoublyLinkedList.h
  4. *
  5. * Copyright (C) 2011 - 2017 David Weenink, 2015 Paul Boersma
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. * See the GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "Data.h"
  21. Thing_define (DoublyLinkedNode, Daata) {
  22. DoublyLinkedNode next, prev;
  23. autoDaata data;
  24. void v_destroy () noexcept
  25. override;
  26. void v_copy (Daata data_to)
  27. override;
  28. };
  29. Thing_define (DoublyLinkedList, Thing) {
  30. integer numberOfNodes;
  31. DoublyLinkedNode front, back;
  32. void v_destroy () noexcept
  33. override;
  34. static int s_compareHook (Daata /* data1 */, Daata /* data2 */) noexcept;
  35. virtual Data_CompareHook v_getCompareHook () { return s_compareHook; }
  36. };
  37. autoDoublyLinkedNode DoublyLinkedNode_create (autoDaata data);
  38. void DoublyLinkedList_init (DoublyLinkedList me);
  39. autoDoublyLinkedList DoublyLinkedList_create ();
  40. void DoublyLinkedList_addFront (DoublyLinkedList me, DoublyLinkedNode n);
  41. void DoublyLinkedList_addBack (DoublyLinkedList me, DoublyLinkedNode n);
  42. void DoublyLinkedList_addBefore (DoublyLinkedList me, DoublyLinkedNode pos, DoublyLinkedNode n);
  43. void DoublyLinkedList_addAfter (DoublyLinkedList me, DoublyLinkedNode pos, DoublyLinkedNode n);
  44. void DoublyLinkedList_remove (DoublyLinkedList me, DoublyLinkedNode n);
  45. void DoublyLinkedList_sort (DoublyLinkedList me);
  46. void DoublyLinkedList_sortPart (DoublyLinkedList me, DoublyLinkedNode from, DoublyLinkedNode to);
  47. #endif // _DoublyLinkedList_h_