Pigweed
C/C++ API Reference
|
Classes | |
class | Item |
Public Member Functions | |
IntrusiveList (const IntrusiveList &)=delete | |
IntrusiveList & | operator= (const IntrusiveList &)=delete |
IntrusiveList (IntrusiveList &&)=default | |
IntrusiveList & | operator= (IntrusiveList &&)=default |
template<typename Iterator > | |
IntrusiveList (Iterator first, Iterator last) | |
IntrusiveList (std::initializer_list< Item * > items) | |
template<typename Iterator > | |
void | assign (Iterator first, Iterator last) |
void | assign (std::initializer_list< T * > items) |
T & | front () |
Reference to the first element in the list. Undefined behavior if empty(). | |
T & | back () |
Reference to the last element in the list. Undefined behavior if empty(). | |
iterator | begin () noexcept |
const_iterator | begin () const noexcept |
const_iterator | cbegin () const noexcept |
iterator | end () noexcept |
const_iterator | end () const noexcept |
const_iterator | cend () const noexcept |
reverse_iterator | rbegin () |
const_reverse_iterator | rbegin () const |
const_reverse_iterator | crbegin () const |
reverse_iterator | rend () |
const_reverse_iterator | rend () const |
const_reverse_iterator | crend () const |
bool | empty () const noexcept |
size_t | size () const |
constexpr size_type | max_size () const noexcept |
void | clear () |
Removes all items from the list. | |
iterator | insert (iterator pos, T &item) |
Inserts the given item before the given position, pos . | |
template<typename Iterator > | |
iterator | insert (iterator pos, Iterator first, Iterator last) |
iterator | insert (iterator pos, std::initializer_list< T * > items) |
iterator | erase (T &item) |
Removes the given item from the list. The item is not destructed. | |
iterator | erase (iterator pos) |
iterator | erase (iterator first, iterator last) |
Removes the range of items from first (inclusive) to last (exclusive). | |
void | push_back (T &item) |
Inserts an element at the end of the list. | |
void | pop_back () |
Removes the last item in the list. The list must not be empty. | |
void | push_front (T &item) |
Inserts an element at the beginning of the list. | |
void | pop_front () |
Removes the first item in the list. The list must not be empty. | |
void | swap (IntrusiveList< T > &other) noexcept |
void | merge (IntrusiveList< T > &other) |
template<typename Compare > | |
void | merge (IntrusiveList< T > &other, Compare comp) |
void | splice (iterator pos, IntrusiveList< T > &other) |
void | splice (iterator pos, IntrusiveList< T > &other, iterator it) |
void | splice (iterator pos, IntrusiveList< T > &other, iterator first, iterator last) |
bool | remove (const T &item) |
template<typename UnaryPredicate > | |
size_type | remove_if (UnaryPredicate pred) |
void | reverse () |
Reverses the order of items in the list. | |
size_type | unique () |
template<typename BinaryPredicate > | |
size_type | unique (BinaryPredicate pred) |
void | sort () |
template<typename Compare > | |
void | sort (Compare comp) |
A doubly-linked intrusive list.
IntrusiveList<T> is a handle to access and manipulate the list, and IntrusiveList<T>::Item is the type from which the base class items must derive.
As a doubly-linked list, operations such as removal are O(1) in time, and the list may be iterated in either direction. However, the overhead needed is 2*sizeof(T*)
.
This class is modeled on std::list
, with the following differences:
iterator
s and not const_iterator
s:erase
is provided that takes a direct reference to an item.T | Type of intrusive items stored in the list. |
|
default |
Clears this list and moves the other list's contents into it.
This is O(1).
|
inline |
Removes all items from the list.
|
inlinenoexcept |
|
inline |
Removes the item following pos
from the list. The item is not destructed.
|
inline |
Inserts the range of items from first
(inclusive) to last
(exclusive) before the given position, pos
.
|
inline |
Inserts the range of items from first
(inclusive) to last
(exclusive) before the given position, pos
.
|
inlineconstexprnoexcept |
Returns how many items can be added.
As an intrusive container, this is effectively unbounded.
|
inline |
Merges the given other
list into this one.
After the call, the list will be sorted according to comp
. The sort is stable, and equivalent items in each list will remain in the same order relative to each other.
This overload uses T::operator<
.
|
inline |
Merges the given other
list into this one.
After the call, the list will be sorted according to comp
. The sort is stable, and equivalent items in each list will remain in the same order relative to each other.
|
default |
Clears this list and moves the other list's contents into it.
This is O(1).
|
inline |
|
inline |
Removes any item for which the given unary predicate function p
evaluates to true when passed that item.
UnaryPredicate | Function with the signature bool(const Item&) |
|
inline |
Reverses the order of items in the list.
|
inline |
|
inline |
|
inline |
|
inline |
Inserts the items of other
to before pos
in this list. Upon returning, other
will be empty.
|
inline |
Moves the items between first
, inclusively, and last
, exclusively from other
to before pos
in this list.
|
inline |
Moves the item pointed to by it
from other
to before pos
in this list.
|
inlinenoexcept |
Exchanges this list's items with the other
list's items.
This is O(1).
|
inline |
|
inline |