Sane C++ Libraries
C++ Platform Abstraction Libraries
Loading...
Searching...
No Matches
IntrusiveDoubleLinkedList.h
1// Copyright (c) Stefano Cristiano
2// SPDX-License-Identifier: MIT
3#pragma once
6namespace SC
7{
16template <typename T>
18{
19 T* back = nullptr; // has no next
20 T* front = nullptr; // has no prev
21
23 [[nodiscard]] bool isEmpty() const { return front == nullptr; }
24
26 [[nodiscard]] T* dequeueFront();
27
29 void clear();
30
33
35 void queueBack(T& item);
36
38 void remove(T& item);
39
40 private:
41 void queueBackUnchecked(T& item, T& newBack);
42};
43} // namespace SC
An Intrusive Double Linked List.
Definition IntrusiveDoubleLinkedList.h:18
bool isEmpty() const
Return true if the linked list is empty.
Definition IntrusiveDoubleLinkedList.h:23
void remove(T &item)
Removes item from this linked list.
T * dequeueFront()
Removes and returns the first element of the linked list.
void queueBack(T &item)
Appends item to the back of this linked list.
void clear()
Clears this linked list removing links between all linked list elements.
void appendBack(IntrusiveDoubleLinkedList &other)
Appends another list at the back of current list.