cycle_ptr
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
cycle_ptr::detail::llist< T, Tag > Class Template Reference

Intrusive linked list. More...

#include <llist.h>

Inheritance diagram for cycle_ptr::detail::llist< T, Tag >:
Inheritance graph
[legend]
Collaboration diagram for cycle_ptr::detail::llist< T, Tag >:
Collaboration graph
[legend]

Classes

class  const_iterator
 Const iterator for llist. More...
 
class  iterator
 Iterator for llist. More...
 

Public Types

using value_type = T
 Value type of the list.
 
using reference = T &
 Reference type of the list.
 
using const_reference = const T &
 Const reference type of the list.
 
using pointer = T *
 Pointer type of the list.
 
using const_pointer = const T *
 Const pointer type of the list.
 
using size_type = std::uintptr_t
 Size type of the list.
 
using reverse_iterator = std::reverse_iterator< iterator >
 Reverse iterator type.
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 Reverse const_iterator type.
 

Public Member Functions

 llist () noexcept
 Default constructor.
 
 llist (const llist &)=delete
 
auto operator= (const llist &) -> llist &=delete
 
 llist (llist &&other) noexcept
 Move constructor.
 
template<typename Iter >
 llist (Iter b, Iter e)
 Range constructor. More...
 
 ~llist () noexcept
 Destructor. More...
 
auto empty () const noexcept -> bool
 Test if this list is empty. More...
 
auto size () const noexcept -> size_type
 Compute the size of the list. More...
 
auto clear () noexcept -> void
 Unlink all elements from the list.
 
auto front () -> T &
 Reference to first item in this list. More...
 
auto front () const -> const T &
 Reference to first item in this list. More...
 
auto back () -> T &
 Reference to last item in this list. More...
 
auto back () const -> const T &
 Reference to last item in this list. More...
 
auto begin () noexcept -> iterator
 Return iterator to first element in the list.
 
auto begin () const noexcept -> const_iterator
 Return iterator to first element in the list.
 
auto cbegin () const noexcept -> const_iterator
 Return iterator to first element in the list.
 
auto end () noexcept -> iterator
 Return iterator past the last element in the list.
 
auto end () const noexcept -> const_iterator
 Return iterator past the last element in the list.
 
auto cend () const noexcept -> const_iterator
 Return iterator past the last element in the list.
 
auto rbegin () noexcept -> reverse_iterator
 Return iterator to first element in reverse iteration.
 
auto rbegin () const noexcept -> const_reverse_iterator
 Return iterator to first element in reverse iteration.
 
auto crbegin () const noexcept -> const_reverse_iterator
 Return iterator to first element in reverse iteration.
 
auto rend () noexcept -> reverse_iterator
 Return iterator past the last element in reverse iteration.
 
auto rend () const noexcept -> const_reverse_iterator
 Return iterator past the last element in reverse iteration.
 
auto crend () const noexcept -> const_reverse_iterator
 Return iterator past the last element in reverse iteration.
 
auto push_back (T &v) noexcept -> void
 Link element into the list, as the last item. More...
 
auto push_front (T &v) noexcept -> void
 Link element into the list, as the first item. More...
 
auto insert (const_iterator pos, T &v) noexcept -> iterator
 Link element into the list. More...
 
template<typename Iter >
auto insert (const_iterator pos, Iter b, Iter e) -> iterator
 Link multiple elements into the list. More...
 
auto pop_front () -> T &
 Unlink the first element in the list. More...
 
auto pop_back () -> T &
 Unlink the last element in the list. More...
 
auto erase (const_iterator b) -> iterator
 Erase element from the list. More...
 
auto erase (const_iterator b, const_iterator e) -> iterator
 Erase elements from the list. More...
 
auto splice (const_iterator pos, llist &other) noexcept -> void
 Splice elements from list. More...
 
auto splice (const_iterator pos, llist &other, const_iterator elem) noexcept -> void
 Splice elements from list. More...
 
auto splice (const_iterator pos, llist &other, const_iterator other_begin, const_iterator other_end) noexcept -> void
 Splice elements from list. More...
 

Static Public Member Functions

static auto iterator_to (T &elem) noexcept -> iterator
 Create iterator to element. More...
 
static auto iterator_to (const T &elem) noexcept -> const_iterator
 Create iterator to element. More...
 

Detailed Description

template<typename T, typename Tag>
class cycle_ptr::detail::llist< T, Tag >

Intrusive linked list.

Template Parameters
TThe element type of the linked list.
TagA tag used to identify the link of the linked list.

Constructor & Destructor Documentation

◆ llist()

template<typename T, typename Tag>
template<typename Iter >
cycle_ptr::detail::llist< T, Tag >::llist ( Iter  b,
Iter  e 
)
inline

Range constructor.

Elements in supplied range will be linked by reference.

Parameters
b,eIterator pair describing a range of elements to insert to the list.

◆ ~llist()

template<typename T, typename Tag>
cycle_ptr::detail::llist< T, Tag >::~llist ( )
inlinenoexcept

Destructor.

Unlinks all elements.

Member Function Documentation

◆ back() [1/2]

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::back ( ) -> T&
inline

Reference to last item in this list.

Undefined behaviour if this list is empty.

Returns
Reference to last element in the list.
Precondition
!this->empty()

◆ back() [2/2]

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::back ( ) const -> const T&
inline

Reference to last item in this list.

Undefined behaviour if this list is empty.

Returns
Reference to last element in the list.
Precondition
!this->empty()

◆ empty()

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::empty ( ) const -> bool
inlinenoexcept

Test if this list is empty.

Returns
True if the list holds no elements, false otherwise.

◆ erase() [1/2]

template<typename T , typename Tag >
auto cycle_ptr::detail::llist< T, Tag >::erase ( const_iterator  b) -> iterator

Erase element from the list.

Returns
Iterator to the element after b.
Precondition
b is a dereferenceable iterator for this list.

◆ erase() [2/2]

template<typename T , typename Tag >
auto cycle_ptr::detail::llist< T, Tag >::erase ( const_iterator  b,
const_iterator  e 
) -> iterator

Erase elements from the list.

Parameters
b,eRange of elements to erase.
Returns
Iterator to the element after b (same as e).
Precondition
range [b,e) is dereferencable for this list.

◆ front() [1/2]

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::front ( ) -> T&
inline

Reference to first item in this list.

Undefined behaviour if this list is empty.

Returns
Reference to first element in the list.
Precondition
!this->empty()

◆ front() [2/2]

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::front ( ) const -> const T&
inline

Reference to first item in this list.

Undefined behaviour if this list is empty.

Returns
Reference to first element in the list.
Precondition
!this->empty()

◆ insert() [1/2]

template<typename T, typename Tag >
auto cycle_ptr::detail::llist< T, Tag >::insert ( const_iterator  pos,
T &  v 
) -> iterator
noexcept

Link element into the list.

Parameters
posIterator to position in front of which the element will be inserted.
vThe element to insert.
Returns
Iterator to v.

◆ insert() [2/2]

template<typename T , typename Tag >
template<typename Iter >
auto cycle_ptr::detail::llist< T, Tag >::insert ( const_iterator  pos,
Iter  b,
Iter  e 
) -> iterator

Link multiple elements into the list.

Parameters
posIterator to position in front of which the element will be inserted.
b,eRange of elements to link into the list.
Returns
Iterator to first element in range [b, e). Or pos if the range is empty.

◆ iterator_to() [1/2]

template<typename T, typename Tag>
static auto cycle_ptr::detail::llist< T, Tag >::iterator_to ( T &  elem) -> iterator
inlinestaticnoexcept

Create iterator to element.

Undefined behaviour if the element is not linked.

Parameters
elemAn element that is on the list.

◆ iterator_to() [2/2]

template<typename T, typename Tag>
static auto cycle_ptr::detail::llist< T, Tag >::iterator_to ( const T &  elem) -> const_iterator
inlinestaticnoexcept

Create iterator to element.

Undefined behaviour if the element is not linked.

Parameters
elemAn element that is on the list.

◆ pop_back()

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::pop_back ( ) -> T&
inline

Unlink the last element in the list.

Undefined behaviour if this list is empty.

Returns
Reference to unlinked element.
Precondition
!this->empty()

◆ pop_front()

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::pop_front ( ) -> T&
inline

Unlink the first element in the list.

Undefined behaviour if this list is empty.

Returns
Reference to unlinked element.
Precondition
!this->empty()

◆ push_back()

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::push_back ( T &  v) -> void
inlinenoexcept

Link element into the list, as the last item.

Postcondition
&this->last() == &v

◆ push_front()

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::push_front ( T &  v) -> void
inlinenoexcept

Link element into the list, as the first item.

Postcondition
&this->front() == &v

◆ size()

template<typename T, typename Tag>
auto cycle_ptr::detail::llist< T, Tag >::size ( ) const -> size_type
inlinenoexcept

Compute the size of the list.

Returns
Number of elements in the list.
Note
Linear complexity, as the list does not maintain an internal size.

◆ splice() [1/3]

template<typename T , typename Tag >
auto cycle_ptr::detail::llist< T, Tag >::splice ( const_iterator  pos,
llist< T, Tag > &  other 
) -> void
noexcept

Splice elements from list.

All elements in other are moved into this list, before pos.

Parameters
posPosition before which the elements are inserted.
otherThe list from which to move elements.
Precondition
this != &other

◆ splice() [2/3]

template<typename T , typename Tag >
auto cycle_ptr::detail::llist< T, Tag >::splice ( const_iterator  pos,
llist< T, Tag > &  other,
const_iterator  elem 
) -> void
noexcept

Splice elements from list.

elem in other is moved into this list, before pos.

Parameters
posPosition before which the elements are inserted.
otherThe list from which to move elements.
elemIterator to the element that is to be moved.
Precondition
elem is a dereferenceable iterator in other.

◆ splice() [3/3]

template<typename T , typename Tag >
auto cycle_ptr::detail::llist< T, Tag >::splice ( const_iterator  pos,
llist< T, Tag > &  other,
const_iterator  other_begin,
const_iterator  other_end 
) -> void
noexcept

Splice elements from list.

elem in other is moved into this list, before pos.

Parameters
posPosition before which the elements are inserted.
otherThe list from which to move elements.
other_begin,other_endRange of elements to move into this list.
Precondition
Range [other_begin, other_end) is a dereferenceable range in other.

The documentation for this class was generated from the following file: