DoublyLinkedList.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. #pragma once
  6. namespace JsUtil
  7. {
  8. template<class T>
  9. class DoublyLinkedList
  10. {
  11. private:
  12. T *head, *tail;
  13. public:
  14. DoublyLinkedList();
  15. public:
  16. T *Head() const;
  17. T *Tail() const;
  18. public:
  19. bool Contains(T *const element) const;
  20. bool ContainsSubsequence(T *const first, T *const last) const;
  21. public:
  22. bool IsEmpty();
  23. void Clear();
  24. void LinkToBeginning(T *const element);
  25. void LinkToEnd(T *const element);
  26. void LinkBefore(T *const element, T *const nextElement);
  27. void LinkAfter(T *const element, T *const previousElement);
  28. T *UnlinkFromBeginning();
  29. T *UnlinkFromEnd();
  30. void UnlinkPartial(T *const element);
  31. void Unlink(T *const element);
  32. void MoveToBeginning(T *const element);
  33. void UnlinkSubsequenceFromEnd(T *const first);
  34. void UnlinkSubsequence(T *const first, T *const last);
  35. void MoveSubsequenceToBeginning(T *const first, T *const last);
  36. // JScriptDiag doesn't seem to like the PREVENT_COPY macro
  37. private:
  38. DoublyLinkedList(const DoublyLinkedList &other);
  39. DoublyLinkedList &operator =(const DoublyLinkedList &other);
  40. };
  41. }