Template Class IntrusiveList

Nested Relationships

Nested Types

Template Parameter Order

  1. typename T

  2. `Node <exhale_struct_structNode_>`_ Member

Class Documentation

template<typename T, Node<T> T::* Member>
class IntrusiveList

Doubly linked intrusive list.

Can be used to link objects in together in a doubly linked list without having the list manage the object. The Node<T> object is used in the managed objects to store the relations

struct Data
{
 Data() : node(this), ... { ... }
 ...
 Node<Data> node;
}

std::array<N, Data> arr;
IntrusiveList<Data, &Data::node> list; // The list object can now be used to link objects in arr
Template Parameters:
  • T – Type of the object that the list has to link

  • T::*Member – Member pointer to the node object in T

Public Types

using Iterator = BaseIterator<T, Node<T>>
using ConstIterator = BaseIterator<const T, const Node<T>>

Public Functions

inline IntrusiveList()

Construct a new Linked List object.

IntrusiveList(const IntrusiveList&) = delete
IntrusiveList &operator=(const IntrusiveList&) = delete
inline IntrusiveList(IntrusiveList &&o)
inline IntrusiveList &operator=(IntrusiveList &&o)
inline void push_back(T &owner)

Push element to the back of the timeout list.

Parameters:

owner – Reference to the owner of the node object that has to be appended to the list

inline void delete_elem(T &owner)

Delete element from the list.

Parameters:

owner – Reference to the owner of the node object that has to be deleted from the list

inline bool in_list(const T &owner) const

Check if element is present in list.

Parameters:

owner – Reference to the owner of the node object to check

Returns:

true Element is present

Returns:

false Element is not present

inline size_t size() const

Get number of objects in list.

Returns:

size_t number of objects in list

inline Iterator begin()
inline Iterator end()
inline ConstIterator begin() const
inline ConstIterator end() const
inline Iterator erase(Iterator position)

Erase element by iterator.

Parameters:

position – Iterator of element that should be deleted

Returns:

Iterator Next element if element has been deleted, argument when it was not present in the list

Friends

inline friend void swap(IntrusiveList &a, IntrusiveList &b)
template<typename It, typename NodeType>
struct BaseIterator

Iterator for IntrusiveList.

Template Parameters:
  • T – Type of the object that the list has to link

  • T::*Member – Member pointer to the node object in T

  • It – Base return type for derefence operator and arrow operator (T or const T)

  • NodeType – Type for storing the Node<T> object (Node<T> or const Node<T>)

Public Functions

inline BaseIterator(NodeType *node_ptr)

Construct a new Iterator object.

Parameters:

node_ptr – Pointer to the node in owner object

inline It &operator*() const

Dereference operator.

Returns:

T& Reference to owner of the node in the iterator

inline It *operator->() const

Arrow operator.

Returns:

T* Pointer to owner of the node in the iterator

inline It &front() const

Front.

Returns:

NodeType& Reference to first element in iterator

inline BaseIterator &operator++()

Prefix increment.

Returns:

Iterator& Reference to the current iterator

inline BaseIterator operator++(int)

Postfix increment.

Returns:

Iterator New iterator with previous value

Friends

inline friend bool operator==(const BaseIterator &a, const BaseIterator &b)
inline friend bool operator!=(const BaseIterator &a, const BaseIterator &b)