CppCommon
1.0.4.1
C++ Common Library
|
Flat map container. More...
#include <flatmap.h>
Public Types | |
typedef TKey | key_type |
typedef TValue | mapped_type |
typedef std::pair< TKey, TValue > | value_type |
typedef value_type & | reference |
typedef const value_type & | const_reference |
typedef value_type * | pointer |
typedef const value_type * | const_pointer |
typedef ptrdiff_t | difference_type |
typedef size_t | size_type |
typedef std::vector< value_type, TAllocator >::iterator | iterator |
typedef std::vector< value_type, TAllocator >::const_iterator | const_iterator |
typedef std::vector< value_type, TAllocator >::reverse_iterator | reverse_iterator |
typedef std::vector< value_type, TAllocator >::const_reverse_iterator | const_reverse_iterator |
Public Member Functions | |
FlatMap (size_t capacity=128, const TCompare &compare=TCompare(), const TAllocator &allocator=TAllocator()) | |
Initialize the flat map with a given capacity. More... | |
template<class InputIterator > | |
FlatMap (InputIterator first, InputIterator last, bool unused, size_t capacity=128, const TCompare &compare=TCompare(), const TAllocator &allocator=TAllocator()) | |
FlatMap (const FlatMap &flatmap) | |
FlatMap (const FlatMap &flatmap, size_t capacity) | |
FlatMap (FlatMap &&) noexcept=default | |
~FlatMap ()=default | |
FlatMap & | operator= (const FlatMap &flatmap) |
FlatMap & | operator= (FlatMap &&) noexcept=default |
operator bool () const noexcept | |
Check if the flat map is not empty. More... | |
mapped_type & | operator[] (const TKey &key) |
Access to the item with the given key or insert a new one. More... | |
bool | empty () const noexcept |
Is the flat map empty? More... | |
size_t | capacity () const noexcept |
Get the flat map capacity. More... | |
size_t | size () const noexcept |
Get the flat map size. More... | |
size_t | max_size () const noexcept |
Get the flat map maximum size. More... | |
bool | compare (const TKey &key1, const TKey &key2) const noexcept |
Compare two items: if the first key is less than the second one? More... | |
bool | compare (const TKey &key1, const value_type &key2) const noexcept |
bool | compare (const value_type &key1, const TKey &key2) const noexcept |
bool | compare (const value_type &key1, const value_type &key2) const noexcept |
iterator | begin () noexcept |
Get the begin flat map iterator. More... | |
const_iterator | begin () const noexcept |
const_iterator | cbegin () const noexcept |
iterator | end () noexcept |
Get the end flat map iterator. More... | |
const_iterator | end () const noexcept |
const_iterator | cend () const noexcept |
reverse_iterator | rbegin () noexcept |
Get the reverse begin flat map iterator. More... | |
const_reverse_iterator | rbegin () const noexcept |
const_reverse_iterator | crbegin () const noexcept |
reverse_iterator | rend () noexcept |
Get the reverse end flat map iterator. More... | |
const_reverse_iterator | rend () const noexcept |
const_reverse_iterator | crend () const noexcept |
iterator | find (const TKey &key) noexcept |
Find the iterator which points to the first item with the given key in the flat map or return end iterator. More... | |
const_iterator | find (const TKey &key) const noexcept |
iterator | lower_bound (const TKey &key) noexcept |
Find the iterator which points to the first item with the given key that not less than the given key in the flat map or return end iterator. More... | |
const_iterator | lower_bound (const TKey &key) const noexcept |
iterator | upper_bound (const TKey &key) noexcept |
Find the iterator which points to the first item with the given key that greater than the given key in the flat map or return end iterator. More... | |
const_iterator | upper_bound (const TKey &key) const noexcept |
std::pair< iterator, iterator > | equal_range (const TKey &key) noexcept |
Find the bounds of a range that includes all the elements in the hash map with the given key. More... | |
std::pair< const_iterator, const_iterator > | equal_range (const TKey &key) const noexcept |
size_t | count (const TKey &key) const noexcept |
Find the count of items with the given key. More... | |
mapped_type & | at (const TKey &key) noexcept |
Access to the item with the given key or throw std::out_of_range exception. More... | |
const mapped_type & | at (const TKey &key) const noexcept |
Access to the constant item with the given key or throw std::out_of_range exception. More... | |
std::pair< iterator, bool > | insert (const value_type &item) |
Insert a new item into the flat map. More... | |
std::pair< iterator, bool > | insert (value_type &&item) |
Insert a new item into the flat map. More... | |
iterator | insert (const const_iterator &position, const value_type &item) |
Insert a new item into the flat map with a position hint. More... | |
iterator | insert (const const_iterator &position, value_type &&item) |
Insert a new item into the flat map with a position hint. More... | |
template<class InputIterator > | |
void | insert (InputIterator first, InputIterator last) |
Insert all items into the flat map from the given iterators range. More... | |
template<typename... Args> | |
std::pair< iterator, bool > | emplace (Args &&... args) |
Emplace a new item into the flat map. More... | |
template<typename... Args> | |
iterator | emplace_hint (const const_iterator &position, Args &&... args) |
Emplace a new item into the flat map with a position hint. More... | |
size_t | erase (const TKey &key) |
Erase the item with the given key from the flat map. More... | |
iterator | erase (const const_iterator &position) |
Erase the item by its iterator from the flat map. More... | |
iterator | erase (const const_iterator &first, const const_iterator &last) |
Erase all items between two given iterators from the flat map. More... | |
void | reserve (size_t count) |
Reserve the flat map capacity to fit the given count of items. More... | |
void | shrink_to_fit () |
Requests the flat map to reduce its capacity to fit its size. More... | |
void | clear () noexcept |
Clear the flat map. More... | |
void | swap (FlatMap &flatmap) noexcept |
Swap two instances. More... | |
template<typename... Args> | |
std::pair< typename FlatMap< TKey, TValue, TCompare, TAllocator >::iterator, bool > | emplace (Args &&... args) |
template<typename... Args> | |
std::pair< typename FlatMap< TKey, TValue, TCompare, TAllocator >::iterator, bool > | emplace_internal (const TKey &key, Args &&... args) |
Friends | |
template<typename UKey , typename UValue , typename UCompare , typename UAllocator > | |
void | swap (FlatMap< UKey, UValue, UCompare, UAllocator > &flatmap1, FlatMap< UKey, UValue, UCompare, UAllocator > &flatmap2) noexcept |
Flat map container.
Flat map is an efficient structure for associative keys/value storing and accessing with keeping order. All key/value items are stored in the sorted array container with using binary search algorithm to find the item by the given key.
Not thread-safe.
typedef std::vector<value_type, TAllocator>::const_iterator CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::const_iterator |
typedef const value_type* CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::const_pointer |
typedef const value_type& CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::const_reference |
typedef std::vector<value_type, TAllocator>::const_reverse_iterator CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::const_reverse_iterator |
typedef ptrdiff_t CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::difference_type |
typedef std::vector<value_type, TAllocator>::iterator CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::iterator |
typedef TKey CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::key_type |
typedef TValue CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::mapped_type |
typedef value_type* CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::pointer |
typedef value_type& CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::reference |
typedef std::vector<value_type, TAllocator>::reverse_iterator CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::reverse_iterator |
typedef size_t CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::size_type |
typedef std::pair<TKey, TValue> CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::value_type |
|
inlineexplicit |
Initialize the flat map with a given capacity.
capacity | - Flat map capacity (default is 128) |
compare | - Key comparator (default is TCompare()) |
allocator | - Allocator (default is TAllocator()) |
Definition at line 12 of file flatmap.inl.
|
inline |
Definition at line 20 of file flatmap.inl.
|
inline |
Definition at line 27 of file flatmap.inl.
|
inline |
Definition at line 35 of file flatmap.inl.
|
defaultnoexcept |
|
default |
|
inlinenoexcept |
Access to the constant item with the given key or throw std::out_of_range exception.
key | - Key of the item |
Definition at line 117 of file flatmap.inl.
|
inlinenoexcept |
Access to the item with the given key or throw std::out_of_range exception.
key | - Key of the item |
Definition at line 107 of file flatmap.inl.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
std::pair<iterator, bool> CppCommon::FlatMap< TKey, TValue, TCompare, TAllocator >::emplace | ( | Args &&... | args | ) |
Emplace a new item into the flat map.
args | - Arguments to emplace |
|
inline |
Definition at line 160 of file flatmap.inl.
|
inline |
Emplace a new item into the flat map with a position hint.
position | - Iterator position to the emplaced item |
args | - Arguments to emplace |
Definition at line 167 of file flatmap.inl.
|
inline |
Definition at line 202 of file flatmap.inl.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Definition at line 101 of file flatmap.inl.
|
inlinenoexcept |
Find the bounds of a range that includes all the elements in the hash map with the given key.
Definition at line 95 of file flatmap.inl.
|
inline |
Erase all items between two given iterators from the flat map.
first | - The first iterator of the erased range |
last | - The last iterator of the erased range |
Definition at line 193 of file flatmap.inl.
|
inline |
Erase the item by its iterator from the flat map.
position | - Iterator position to the erased item |
Definition at line 184 of file flatmap.inl.
|
inline |
Erase the item with the given key from the flat map.
key | - Key of the item to erase |
Definition at line 173 of file flatmap.inl.
|
inlinenoexcept |
Definition at line 62 of file flatmap.inl.
|
inlinenoexcept |
Find the iterator which points to the first item with the given key in the flat map or return end iterator.
Definition at line 53 of file flatmap.inl.
|
inline |
Insert a new item into the flat map with a position hint.
position | - Iterator position to the inserted item |
item | - Item to insert as a key/value pair |
Definition at line 139 of file flatmap.inl.
|
inline |
Insert a new item into the flat map with a position hint.
position | - Iterator position to the inserted item |
item | - Item to insert as a key/value pair |
Definition at line 145 of file flatmap.inl.
|
inline |
Insert a new item into the flat map.
item | - Item to insert as a key/value pair |
Definition at line 127 of file flatmap.inl.
|
inline |
Insert all items into the flat map from the given iterators range.
first | - The first iterator of the inserted range |
last | - The last iterator of the inserted range |
Definition at line 152 of file flatmap.inl.
|
inline |
Insert a new item into the flat map.
item | - Item to insert as a key/value pair |
Definition at line 133 of file flatmap.inl.
|
inlinenoexcept |
Definition at line 77 of file flatmap.inl.
|
inlinenoexcept |
Find the iterator which points to the first item with the given key that not less than the given key in the flat map or return end iterator.
Definition at line 71 of file flatmap.inl.
|
inlinenoexcept |
|
inlineexplicitnoexcept |
|
inline |
Definition at line 43 of file flatmap.inl.
|
defaultnoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
Swap two instances.
Definition at line 224 of file flatmap.inl.
|
inlinenoexcept |
Definition at line 89 of file flatmap.inl.
|
inlinenoexcept |
Find the iterator which points to the first item with the given key that greater than the given key in the flat map or return end iterator.
Definition at line 83 of file flatmap.inl.
|
friend |