template<class Type>
bn::intrusive_list class

Intrusive list implementation.

Template parameters
Type Element type (it must inherit intrusive_list_node_type class).

Public types

class const_iterator
Const iterator.
class iterator
Non const iterator.
using value_type = Type
Value type alias.
using size_type = int
Size type alias.
using difference_type = int
Difference type alias.
using reference = Type&
Reference alias.
using const_reference = const Type&
Const reference alias.
using pointer = Type*
Pointer alias.
using const_pointer = const Type*
Const pointer alias.
using reverse_iterator = bn::reverse_iterator<iterator>
Reverse iterator alias.
using const_reverse_iterator = bn::reverse_iterator<const_iterator>
Const reverse iterator alias.

Constructors, destructors, conversion operators

intrusive_list()
Default constructor.
intrusive_list(intrusive_list&& other) noexcept
Move constructor.
~intrusive_list() noexcept
Destructor.

Public functions

auto operator=(intrusive_list&& other) -> intrusive_list& noexcept
Move assignment operator.
auto size() const -> size_type
Returns the current size.
auto empty() const -> bool
Indicates if it doesn't contain any element.
auto begin() const -> const_iterator
Returns a const iterator to the beginning of the intrusive_list.
auto begin() -> iterator
Returns an iterator to the beginning of the intrusive_list.
auto end() const -> const_iterator
Returns a const iterator to the end of the intrusive_list.
auto end() -> iterator
Returns an iterator to the end of the intrusive_list.
auto cbegin() const -> const_iterator
Returns a const iterator to the beginning of the intrusive_list.
auto cend() const -> const_iterator
Returns a const iterator to the end of the intrusive_list.
auto rbegin() const -> const_reverse_iterator
Returns a const reverse iterator to the end of the intrusive_list.
auto rbegin() -> reverse_iterator
Returns a reverse iterator to the end of the intrusive_list.
auto rend() const -> const_reverse_iterator
Returns a const reverse iterator to the beginning of the intrusive_list.
auto rend() -> reverse_iterator
Returns a reverse iterator to the beginning of the intrusive_list.
auto crbegin() const -> const_reverse_iterator
Returns a const reverse iterator to the end of the intrusive_list.
auto crend() const -> const_reverse_iterator
Returns a const reverse iterator to the beginning of the intrusive_list.
auto front() const -> const_reference
Returns a const reference to the first element.
auto front() -> reference
Returns a reference to the first element.
auto back() const -> const_reference
Returns a const reference to the last element.
auto back() -> reference
Returns a reference to the last element.
void push_front(reference value)
Inserts a value at the beginning of the intrusive_list.
void push_back(reference value)
Inserts a value at the end of the intrusive_list.
void pop_front()
Removes the first element of the intrusive_list.
void pop_back()
Removes the last element of the intrusive_list.
auto insert(const_iterator position, reference value) -> iterator
Inserts a value at the specified position.
auto insert(reference position_value, reference value) -> iterator
Inserts a value at the specified position.
auto erase(const_iterator position) -> iterator
Erases an element.
auto erase(reference value) -> iterator
Erases an element.
auto erase(const_iterator first, const_iterator last) -> iterator
Erases a range of elements.
template<typename Iterator>
void assign(const Iterator& first, const Iterator& last)
Assigns values to the intrusive_list, removing the previous ones.
void clear()
Removes all elements.
void swap(intrusive_list& other)
Exchanges the contents of this intrusive_list with those of the other one.

Friends

auto erase(intrusive_list& list, const_reference value) -> size_type
Erases all elements that are equal to the specified value.
template<class Pred>
auto erase_if(intrusive_list& list, const Pred& pred) -> size_type
Erases all elements that satisfy the specified predicate.
void swap(intrusive_list& a, intrusive_list& b)
Exchanges the contents of a intrusive_list with those of another one.
auto operator==(const intrusive_list& a, const intrusive_list& b) -> bool
Equal operator.
auto operator!=(const intrusive_list& a, const intrusive_list& b) -> bool
Not equal operator.
auto operator<(const intrusive_list& a, const intrusive_list& b) -> bool
Less than operator.
auto operator>(const intrusive_list& a, const intrusive_list& b) -> bool
Greater than operator.
auto operator<=(const intrusive_list& a, const intrusive_list& b) -> bool
Less than or equal operator.
auto operator>=(const intrusive_list& a, const intrusive_list& b) -> bool
Greater than or equal operator.

Function documentation

template<class Type>
bn::intrusive_list<Type>::intrusive_list(intrusive_list&& other) noexcept

Move constructor.

Parameters
other intrusive_list to move.

template<class Type>
intrusive_list& bn::intrusive_list<Type>::operator=(intrusive_list&& other) noexcept

Move assignment operator.

Parameters
other intrusive_list to move.
Returns Reference to this.

template<class Type>
void bn::intrusive_list<Type>::push_front(reference value)

Inserts a value at the beginning of the intrusive_list.

Parameters
value Value to insert.

template<class Type>
void bn::intrusive_list<Type>::push_back(reference value)

Inserts a value at the end of the intrusive_list.

Parameters
value Value to insert.

template<class Type>
iterator bn::intrusive_list<Type>::insert(const_iterator position, reference value)

Inserts a value at the specified position.

Parameters
position The given value is inserted before this position.
value Value to insert.
Returns Iterator pointing to the inserted value.

template<class Type>
iterator bn::intrusive_list<Type>::insert(reference position_value, reference value)

Inserts a value at the specified position.

Parameters
position_value The given value is inserted before the position of this value in the intrusive_list.
value Value to insert.
Returns Iterator pointing to the inserted value.

template<class Type>
iterator bn::intrusive_list<Type>::erase(const_iterator position)

Erases an element.

Parameters
position Iterator to the element to erase.
Returns Iterator following the erased element.

template<class Type>
iterator bn::intrusive_list<Type>::erase(reference value)

Erases an element.

Parameters
value Element to erase.
Returns Iterator following the erased element.

template<class Type>
iterator bn::intrusive_list<Type>::erase(const_iterator first, const_iterator last)

Erases a range of elements.

Parameters
first Iterator to the first element to erase.
last Iterator to the last element to erase.
Returns Iterator following the last erased element.

The range includes all the elements between first and last, including the element pointed by first, but not the one pointed by last.

template<class Type> template<typename Iterator>
void bn::intrusive_list<Type>::assign(const Iterator& first, const Iterator& last)

Assigns values to the intrusive_list, removing the previous ones.

Parameters
first Iterator to the first element to insert.
last Iterator following to the last element to insert.

template<class Type>
void bn::intrusive_list<Type>::swap(intrusive_list& other)

Exchanges the contents of this intrusive_list with those of the other one.

Parameters
other intrusive_list to exchange the contents with.

template<class Type>
size_type erase(intrusive_list& list, const_reference value)

Erases all elements that are equal to the specified value.

Parameters
list intrusive_list from which to erase.
value Element to erase.
Returns Number of erased elements.

template<class Type> template<class Pred>
size_type erase_if(intrusive_list& list, const Pred& pred)

Erases all elements that satisfy the specified predicate.

Parameters
list intrusive_list from which to erase.
pred Unary predicate which returns true if the element should be erased.
Returns Number of erased elements.

template<class Type>
void swap(intrusive_list& a, intrusive_list& b)

Exchanges the contents of a intrusive_list with those of another one.

Parameters
a First intrusive_list to exchange the contents with.
b Second intrusive_list to exchange the contents with.

template<class Type>
bool operator==(const intrusive_list& a, const intrusive_list& b)

Equal operator.

Parameters
a First intrusive_list to compare.
b Second intrusive_list to compare.
Returns true if the first intrusive_list is equal to the second one, otherwise false.

template<class Type>
bool operator!=(const intrusive_list& a, const intrusive_list& b)

Not equal operator.

Parameters
a First intrusive_list to compare.
b Second intrusive_list to compare.
Returns true if the first intrusive_list is not equal to the second one, otherwise false.

template<class Type>
bool operator<(const intrusive_list& a, const intrusive_list& b)

Less than operator.

Parameters
a First intrusive_list to compare.
b Second intrusive_list to compare.
Returns true if the first intrusive_list is lexicographically less than the second one, otherwise false.

template<class Type>
bool operator>(const intrusive_list& a, const intrusive_list& b)

Greater than operator.

Parameters
a First intrusive_list to compare.
b Second intrusive_list to compare.
Returns true if the first intrusive_list is lexicographically greater than the second one, otherwise false.

template<class Type>
bool operator<=(const intrusive_list& a, const intrusive_list& b)

Less than or equal operator.

Parameters
a First intrusive_list to compare.
b Second intrusive_list to compare.
Returns true if the first intrusive_list is lexicographically less than or equal to the second one, otherwise false.

template<class Type>
bool operator>=(const intrusive_list& a, const intrusive_list& b)

Greater than or equal operator.

Parameters
a First intrusive_list to compare.
b Second intrusive_list to compare.
Returns true if the first intrusive_list is lexicographically greater than or equal to the second one, otherwise false.