cpp-stat-bench 0.24.0
Benchmark library with statistics for C++.
Loading...
Searching...
No Matches
stat_bench::util::OrderedMap< Key, MappedValue > Class Template Reference

Class of mapping which preserves order of insertion. More...

#include <stat_bench/util/ordered_map.h>

+ Inheritance diagram for stat_bench::util::OrderedMap< Key, MappedValue >:
+ Collaboration diagram for stat_bench::util::OrderedMap< Key, MappedValue >:

Public Types

using const_iterator
 Type of iterators.
 
using iterator
 Type of iterators.
 

Public Member Functions

 OrderedMap ()=default
 Constructor.
 
 OrderedMap (std::initializer_list< std::pair< Key, MappedValue > > initializer_list)
 Constructor.
 
auto at (const Key &key) const -> const MappedValue &
 Access a mapped value.
 
auto begin () -> iterator
 Get an iterator pointing to the beginning of pairs.
 
auto begin () const -> const_iterator
 Get an iterator pointing to the beginning of pairs.
 
auto count (const Key &key) const -> std::size_t
 Count the number of pairs with a key.
 
template<typename... Args>
auto emplace (Args &&... args) -> std::pair< iterator, bool >
 Insert a pair.
 
auto empty () const noexcept -> bool
 Check whether this mapping is empty.
 
auto end () -> iterator
 Get an iterator pointing to the end of pairs.
 
auto end () const -> const_iterator
 Get an iterator pointing to the end of pairs.
 
auto erase (const_iterator iter) -> iterator
 Erase a pair.
 
auto find (const Key &key) const -> const_iterator
 Find a pair with a key.
 
auto operator!= (const OrderedMap &rhs) const -> bool
 Check whether this is not equal to another mapping.
 
auto operator== (const OrderedMap &rhs) const -> bool
 Check whether this is equal to another mapping.
 
auto operator[] (const Key &key) -> MappedValue &
 Access a mapped value.
 
auto pairs () const noexcept -> const std::vector< std::pair< Key, MappedValue > > &
 Get pairs.
 
void reserve (std::size_t size)
 Reserve memory space.
 
auto size () const noexcept -> std::size_t
 Get the number of pairs.
 
template<typename... Args>
auto try_emplace (const Key &key, Args &&... args) -> std::pair< iterator, bool >
 Insert a pair if the key does not exist.
 

Detailed Description

template<typename Key, typename MappedValue>
class stat_bench::util::OrderedMap< Key, MappedValue >

Class of mapping which preserves order of insertion.

Template Parameters
KeyType of keys.
MappedValueType of mapped values.

Definition at line 39 of file ordered_map.h.

Member Typedef Documentation

◆ const_iterator

template<typename Key, typename MappedValue>
using stat_bench::util::OrderedMap< Key, MappedValue >::const_iterator
Initial value:
typename std::vector<std::pair<Key, MappedValue>>::const_iterator
typename std::vector< std::pair< Key, MappedValue > >::const_iterator const_iterator
Type of iterators.
Definition ordered_map.h:46

Type of iterators.

Definition at line 46 of file ordered_map.h.

◆ iterator

template<typename Key, typename MappedValue>
using stat_bench::util::OrderedMap< Key, MappedValue >::iterator
Initial value:
typename std::vector<std::pair<Key, MappedValue>>::iterator
typename std::vector< std::pair< Key, MappedValue > >::iterator iterator
Type of iterators.
Definition ordered_map.h:42

Type of iterators.

Definition at line 42 of file ordered_map.h.

Constructor & Destructor Documentation

◆ OrderedMap()

template<typename Key, typename MappedValue>
stat_bench::util::OrderedMap< Key, MappedValue >::OrderedMap ( std::initializer_list< std::pair< Key, MappedValue > > initializer_list)
inline

Constructor.

Parameters
[in]initializer_listInitializer list.

Definition at line 59 of file ordered_map.h.

Member Function Documentation

◆ at()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::at ( const Key & key) const -> const MappedValue&
inlinenodiscard

Access a mapped value.

Parameters
[in]keyKey.
Returns
Mapped value.
Note
If the key does not exist, an exception is thrown.

Definition at line 187 of file ordered_map.h.

◆ begin() [1/2]

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::begin ( ) -> iterator
inlinenodiscard

Get an iterator pointing to the beginning of pairs.

Returns
Iterator.

Definition at line 210 of file ordered_map.h.

◆ begin() [2/2]

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::begin ( ) const -> const_iterator
inlinenodiscard

Get an iterator pointing to the beginning of pairs.

Returns
Iterator.

Definition at line 217 of file ordered_map.h.

◆ count()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::count ( const Key & key) const -> std::size_t
inlinenodiscard

Count the number of pairs with a key.

Parameters
[in]keyKey.
Returns
Number of pairs with the key.

Definition at line 91 of file ordered_map.h.

◆ emplace()

template<typename Key, typename MappedValue>
template<typename... Args>
auto stat_bench::util::OrderedMap< Key, MappedValue >::emplace ( Args &&... args) -> std::pair<iterator, bool>
inline

Insert a pair.

Template Parameters
ArgsTypes of arguments.
Parameters
[in]argsArguments.
Returns
A pair of the iterator and whether the insertion is successful.

Definition at line 113 of file ordered_map.h.

◆ empty()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::empty ( ) const -> bool
inlinenodiscardnoexcept

Check whether this mapping is empty.

Return values
trueThis mapping is empty.
falseThis mapping is not empty.

Definition at line 72 of file ordered_map.h.

◆ end() [1/2]

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::end ( ) -> iterator
inlinenodiscard

Get an iterator pointing to the end of pairs.

Returns
Iterator.

Definition at line 226 of file ordered_map.h.

◆ end() [2/2]

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::end ( ) const -> const_iterator
inlinenodiscard

Get an iterator pointing to the end of pairs.

Returns
Iterator.

Definition at line 233 of file ordered_map.h.

◆ erase()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::erase ( const_iterator iter) -> iterator
inline

Erase a pair.

Parameters
[in]iterIterator pointing to the pair.
Returns
Iterator pointing to the next pair.

Definition at line 151 of file ordered_map.h.

◆ find()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::find ( const Key & key) const -> const_iterator
inlinenodiscard

Find a pair with a key.

Parameters
[in]keyKey.
Returns
Iterator pointing to the pair. If not found, end() is returned.

Definition at line 197 of file ordered_map.h.

◆ operator!=()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::operator!= ( const OrderedMap< Key, MappedValue > & rhs) const -> bool
inlinenodiscard

Check whether this is not equal to another mapping.

Parameters
[in]rhsRight-hand-side mapping.
Return values
trueThis is not equal to the right-hand-side mapping.
falseThis is equal to the right-hand-side mapping.

Definition at line 262 of file ordered_map.h.

◆ operator==()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::operator== ( const OrderedMap< Key, MappedValue > & rhs) const -> bool
inlinenodiscard

Check whether this is equal to another mapping.

Parameters
[in]rhsRight-hand-side mapping.
Return values
trueThis is equal to the right-hand-side mapping.
falseThis is not equal to the right-hand-side mapping.

Definition at line 242 of file ordered_map.h.

◆ operator[]()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::operator[] ( const Key & key) -> MappedValue&
inlinenodiscard

Access a mapped value.

Parameters
[in]keyKey.
Returns
Mapped value.
Note
If the key does not exist, a new pair is inserted.

Definition at line 169 of file ordered_map.h.

◆ pairs()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::pairs ( ) const -> const std::vector<std::pair<Key, MappedValue>>&
inlinenodiscardnoexcept

Get pairs.

Returns
Pairs.

Definition at line 271 of file ordered_map.h.

◆ reserve()

template<typename Key, typename MappedValue>
void stat_bench::util::OrderedMap< Key, MappedValue >::reserve ( std::size_t size)
inline

Reserve memory space.

Parameters
[in]sizeNumber of pairs.

Definition at line 100 of file ordered_map.h.

◆ size()

template<typename Key, typename MappedValue>
auto stat_bench::util::OrderedMap< Key, MappedValue >::size ( ) const -> std::size_t
inlinenodiscardnoexcept

Get the number of pairs.

Returns
Number of pairs.

Definition at line 81 of file ordered_map.h.

◆ try_emplace()

template<typename Key, typename MappedValue>
template<typename... Args>
auto stat_bench::util::OrderedMap< Key, MappedValue >::try_emplace ( const Key & key,
Args &&... args ) -> std::pair<iterator, bool>
inline

Insert a pair if the key does not exist.

Template Parameters
ArgsTypes of arguments.
Parameters
[in]keyKey.
[in]argsArguments.
Returns
A pair of the iterator and whether the insertion is successful.

Definition at line 133 of file ordered_map.h.


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