Pigweed
C/C++ API Reference
|
Classes | |
class | const_iterator |
class | iterator |
Public Types | |
using | Item = typename Tree::Item |
using | Pair = typename Tree::Pair |
using | key_type = Key |
using | mapped_type = std::remove_cv_t< T > |
using | value_type = Item |
using | size_type = std::size_t |
using | difference_type = std::ptrdiff_t |
using | key_compare = Compare |
using | reference = value_type & |
using | const_reference = const value_type & |
using | pointer = value_type * |
using | const_pointer = const value_type * |
using | reverse_iterator = std::reverse_iterator< iterator > |
using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
Public Member Functions | |
constexpr | IntrusiveMap () |
Constructs an empty map of items. | |
template<typename Comparator > | |
constexpr | IntrusiveMap (Comparator compare) |
template<typename Comparator , typename KeyRetriever > | |
constexpr | IntrusiveMap (Comparator &&compare, KeyRetriever &&get_key) |
template<typename Iterator , typename... Functors> | |
IntrusiveMap (Iterator first, Iterator last, Functors &&... functors) | |
template<typename... Functors> | |
IntrusiveMap (std::initializer_list< T * > items, Functors &&... functors) | |
T & | at (const key_type &key) |
const T & | at (const key_type &key) const |
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 () noexcept |
const_reverse_iterator | rbegin () const noexcept |
const_reverse_iterator | crbegin () const noexcept |
reverse_iterator | rend () noexcept |
const_reverse_iterator | rend () const noexcept |
const_reverse_iterator | crend () const noexcept |
bool | empty () const noexcept |
Returns whether the map has zero items or not. | |
size_t | size () const |
Returns the number of items in the map. | |
constexpr size_t | max_size () const noexcept |
void | clear () |
std::pair< iterator, bool > | insert (T &item) |
iterator | insert (iterator, T &item) |
template<class Iterator > | |
void | insert (Iterator first, Iterator last) |
void | insert (std::initializer_list< T * > ilist) |
iterator | erase (T &item) |
iterator | erase (iterator pos) |
iterator | erase (iterator first, iterator last) |
size_t | erase (const key_type &key) |
void | swap (IntrusiveMap< Key, T > &other) |
Exchanges this map's items with the other map's items. | |
template<typename MapType > | |
void | merge (MapType &other) |
Splices items from the other map into this one. | |
size_t | count (const key_type &key) const |
iterator | find (const key_type &key) |
const_iterator | find (const key_type &key) const |
std::pair< iterator, iterator > | equal_range (const key_type &key) |
std::pair< const_iterator, const_iterator > | equal_range (const key_type &key) const |
iterator | lower_bound (const key_type &key) |
const_iterator | lower_bound (const key_type &key) const |
iterator | upper_bound (const key_type &key) |
const_iterator | upper_bound (const key_type &key) const |
Friends | |
template<typename , typename > | |
class | IntrusiveMultiMap |
A std::map<Key, T, Compare>
-like class that uses intrusive items.
Since the map structure is stored in the items themselves, each item must outlive any map it is a part of and must be part of at most one map.
This map requires unique keys. Attempting to add an item with same key as an item already in the map will fail.
iterator
s and not const_iterator
s:erase
is provided that takes a direct reference to an item.Key | Type to sort items on |
T | Type of values stored in the map. |
using pw::IntrusiveMap< Key, T >::Item = typename Tree::Item |
IntrusiveMap items must derive from either Item
or Pair
. Use Pair
to automatically provide storage for a Key
. Use Item
when the derived type has a key()
accessor method or when the map provides a custom GetKey
function object.
|
inlineexplicitconstexpr |
Constructs an empty map of items.
SFINAE is used to disambiguate between this constructor and the one that takes an initializer list.
compare | Function with the signature bool(Key, Key) that is used to order items. |
|
inlineconstexpr |
Constructs an empty map of items.
compare | Function with the signature bool(Key, Key) that is used to order items. |
get_key | Function with signature Key(const T&) that returns the value that items are sorted on. |
|
inline |
Constructs an IntrusiveMap from an iterator over Items.
The iterator may dereference as either Item& (e.g. from std::array<Item>) or Item* (e.g. from std::initializer_list<Item*>).
|
inlineexplicit |
Constructs an IntrusiveMap from a std::initializer_list of pointers to items.
|
inline |
Returns a reference to the item associated with the given key.
|
inline |
Removes all items from the map and leaves it empty.
The items themselves are not destructed.
|
inline |
Returns the number of items in the map with the given key.
Since the map requires unique keys, this is always 0 or 1.
|
inline |
Returns a pair of iterators where the first points to the item with the smallest key that is not less than the given key, and the second points to the item with the smallest key that is greater than the given key.
|
inline |
Removes an item from the map and returns an iterator to the item after the removed item..
The items themselves are not destructed.
|
inline |
Returns a pointer to an item with the given key, or null if the map does not contain such an item.
|
inline |
Attempts to add the given item to the map.
The item will be added if the map does not already contain an item with the given item's key.
true
, or a pointer to the existing item with same key and false
.
|
inline |
Returns an iterator to the item in the map with the smallest key that is greater than or equal to the given key, or end()
if the map is empty.
|
inlineconstexprnoexcept |
Returns how many items can be added.
As an intrusive container, this is effectively unbounded.
|
inline |
Returns an iterator to the item in the map with the smallest key that is strictly greater than the given key, or end()
if the map is empty.