Pigweed
 
Loading...
Searching...
No Matches
pw::containers::internal::GenericIntrusiveList< Item > Class Template Reference

#include <intrusive_list.h>

Public Member Functions

template<typename Iterator >
 GenericIntrusiveList (Iterator first, Iterator last)
 
 GenericIntrusiveList (const GenericIntrusiveList &)=delete
 
GenericIntrusiveListoperator= (const GenericIntrusiveList &)=delete
 
 GenericIntrusiveList (GenericIntrusiveList &&other)
 
GenericIntrusiveListoperator= (GenericIntrusiveList &&other)
 
template<typename Iterator >
void assign (Iterator first, Iterator last)
 
constexpr Item * before_begin () noexcept
 Returns a pointer to the sentinel item.
 
constexpr const Item * before_begin () const noexcept
 
constexpr Item * begin () noexcept
 Returns a pointer to the first item.
 
constexpr const Item * begin () const noexcept
 
Item * before_end () noexcept
 Returns a pointer to the last item.
 
constexpr Item * end () noexcept
 Returns a pointer to the sentinel item.
 
constexpr const Item * end () const noexcept
 
bool empty () const noexcept
 
constexpr size_t max_size () const noexcept
 
void clear ()
 Removes all items from the list.
 
void swap (GenericIntrusiveList< Item > &other)
 
template<typename Compare >
void merge (GenericIntrusiveList< Item > &other, Compare comp)
 
bool remove (const Item &item_to_remove)
 
template<typename UnaryPredicate >
size_t remove_if (UnaryPredicate pred, size_t max=std::numeric_limits< size_t >::max())
 
void reverse ()
 Reverses the order of items in the list.
 
template<typename BinaryPredicate >
size_t unique (BinaryPredicate pred)
 
template<typename Compare >
void sort (Compare comp)
 

Static Public Member Functions

static Item * insert_after (Item *prev, Item &item)
 
template<typename Iterator >
static Item * insert_after (Item *prev, Iterator first, Iterator last)
 
static Item * erase_after (Item *item)
 
static Item * erase_after (Item *first, Item *last)
 Removes the range of items exclusively between first and last.
 
static void splice_after (Item *pos, GenericIntrusiveList< Item > &other, Item *first, Item *last)
 

Detailed Description

template<typename Item>
class pw::containers::internal::GenericIntrusiveList< Item >

Generic intrusive list implementation.

This implementation relies on the Item type to provide details of how to navigate the list. It provides methods similar to std::forward_list and std::list.

Template Parameters
ItemThe type used to intrusive store list pointers.

Member Function Documentation

◆ erase_after()

template<typename Item >
static Item * pw::containers::internal::GenericIntrusiveList< Item >::erase_after ( Item *  item)
inlinestatic

Removes an item from a list.

The item after the given item is unlisted, and the item following it is returned.

This is O(1). The item is not destroyed..

◆ insert_after() [1/2]

template<typename Item >
static Item * pw::containers::internal::GenericIntrusiveList< Item >::insert_after ( Item *  prev,
Item &  item 
)
inlinestatic

Inserts an item into a list.

The item given by prev is updated to point to the item as being next in the list, while the item itself points to what prev previously pointed to as next.

This is O(1). The ownership of the item is not changed.

Returns
The item that was added.

◆ insert_after() [2/2]

template<typename Item >
template<typename Iterator >
static Item * pw::containers::internal::GenericIntrusiveList< Item >::insert_after ( Item *  prev,
Iterator  first,
Iterator  last 
)
inlinestatic

Adds items to the list from the provided range after the given item.

This is O(n), where "n" is the number of items in the range.

Returns
The last item that was added.

◆ max_size()

template<typename Item >
constexpr size_t pw::containers::internal::GenericIntrusiveList< Item >::max_size ( ) const
inlineconstexprnoexcept

Returns how many items can be added.

As an intrusive container, this is effectively unbounded.

◆ merge()

template<typename Item >
template<typename Compare >
void pw::containers::internal::GenericIntrusiveList< Item >::merge ( GenericIntrusiveList< Item > &  other,
Compare  comp 
)
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.

◆ remove_if()

template<typename Item >
template<typename UnaryPredicate >
size_t pw::containers::internal::GenericIntrusiveList< Item >::remove_if ( UnaryPredicate  pred,
size_t  max = std::numeric_limits<size_t>::max() 
)
inline

Removes any item for which the given unary predicate function p evaluates to true when passed that item.

Template Parameters
UnaryPredicateFunction with the signature bool(const Item&)
Returns
The number of items removed.

◆ sort()

template<typename Item >
template<typename Compare >
void pw::containers::internal::GenericIntrusiveList< Item >::sort ( Compare  comp)
inline

Rearranges the items in the list such that the given comparison function comp evaluates to true for each pair of successive items.

Template Parameters
BinaryPredicateFunction with the signature bool(const Item&, const Item&)

◆ splice_after()

template<typename Item >
static void pw::containers::internal::GenericIntrusiveList< Item >::splice_after ( Item *  pos,
GenericIntrusiveList< Item > &  other,
Item *  first,
Item *  last 
)
inlinestatic

Moves the items exclusively between first and last from other to after pos in this list.

◆ unique()

template<typename Item >
template<typename BinaryPredicate >
size_t pw::containers::internal::GenericIntrusiveList< Item >::unique ( BinaryPredicate  pred)
inline

Removes consecutive ietms that are equivalent accroding to the given binary predicate p, leaving only the first item in the list.

Template Parameters
BinaryPredicateFunction with the signature bool(const Item&, const Item&)

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