WPILibC++ 2025.2.1
|
StringMap is a sorted associative container that contains key-value pairs with unique string keys. More...
#include <wpi/StringMap.h>
Public Types | |
using | map_type = typename std::map<std::string, T, std::less<>> |
using | key_type = typename map_type::key_type |
using | mapped_type = typename map_type::mapped_type |
using | value_type = typename map_type::value_type |
using | size_type = typename map_type::size_type |
using | difference_type = typename map_type::difference_type |
using | key_compare = typename map_type::key_compare |
using | allocator_type = typename map_type::allocator_type |
using | reference = typename map_type::reference |
using | const_reference = typename map_type::const_reference |
using | pointer = typename map_type::pointer |
using | const_pointer = typename map_type::const_pointer |
using | iterator = typename map_type::iterator |
using | const_iterator = typename map_type::const_iterator |
using | reverse_iterator = typename map_type::reverse_iterator |
using | const_reverse_iterator = typename map_type::const_reverse_iterator |
using | node_type = typename map_type::node_type |
using | insert_return_type = typename map_type::insert_return_type |
Public Member Functions | |
StringMap ()=default | |
Constructs an empty container. | |
StringMap (const Allocator &alloc) | |
Constructs an empty container. | |
template<typename InputIt > | |
StringMap (InputIt first, InputIt last, const Allocator &alloc=Allocator()) | |
Constructs the container with the contents of the range [first, last). | |
StringMap (const StringMap &)=default | |
Copy constructor. | |
StringMap (const StringMap &other, const Allocator &alloc) | |
Copy constructor. | |
StringMap (StringMap &&)=default | |
Move constructor. | |
StringMap (StringMap &&other, const Allocator &alloc) | |
Move constructor. | |
StringMap (std::initializer_list< value_type > init, const Allocator &alloc=Allocator()) | |
Initializer-list constructor. | |
StringMap & | operator= (const StringMap &)=default |
Copy assignment operator. | |
StringMap & | operator= (StringMap &&) noexcept(std::allocator_traits< Allocator >::is_always_equal::value &&std::is_nothrow_move_assignable< std::less<> >::value)=default |
Move assignment operator. | |
StringMap & | operator= (std::initializer_list< value_type > ilist) |
Replaces the contents with those identified by initializer list ilist. | |
T & | at (const std::string &key) |
Returns a reference to the mapped value of the element with the specified key. | |
const T & | at (const std::string &key) const |
Returns a reference to the mapped value of the element with the specified key. | |
T & | at (const char *key) |
Returns a reference to the mapped value of the element with the specified key. | |
const T & | at (const char *key) const |
Returns a reference to the mapped value of the element with the specified key. | |
T & | at (std::string_view key) |
Returns a reference to the mapped value of the element with the specified key. | |
const T & | at (std::string_view key) const |
Returns a reference to the mapped value of the element with the specified key. | |
T & | operator[] (const std::string &key) |
Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist. | |
T & | operator[] (std::string &&key) |
Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist. | |
T & | operator[] (const char *key) |
Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist. | |
T & | operator[] (std::string_view key) |
Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist. | |
template<typename M > | |
std::pair< iterator, bool > | insert_or_assign (std::string &&key, M &&obj) |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key. | |
template<typename M > | |
std::pair< iterator, bool > | insert_or_assign (const char *key, M &&obj) |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key. | |
template<typename M > | |
std::pair< iterator, bool > | insert_or_assign (std::string_view key, M &&obj) |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key. | |
template<typename M > | |
iterator | insert_or_assign (const_iterator hint, std::string &&key, M &&obj) |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key. | |
template<typename M > | |
iterator | insert_or_assign (const_iterator hint, const char *key, M &&obj) |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key. | |
template<typename M > | |
iterator | insert_or_assign (const_iterator hint, std::string_view key, M &&obj) |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key. | |
template<typename... Args> | |
std::pair< iterator, bool > | emplace (std::string &&key, Args &&... args) |
Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container. | |
template<typename... Args> | |
std::pair< iterator, bool > | emplace (const char *key, Args &&... args) |
Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container. | |
template<typename... Args> | |
std::pair< iterator, bool > | emplace (std::string_view key, Args &&... args) |
Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container. | |
template<typename... Args> | |
std::pair< iterator, bool > | try_emplace (std::string &&key, Args &&... args) |
If a key equal to key already exists in the container, does nothing. | |
template<typename... Args> | |
std::pair< iterator, bool > | try_emplace (const char *key, Args &&... args) |
If a key equal to key already exists in the container, does nothing. | |
template<typename... Args> | |
std::pair< iterator, bool > | try_emplace (std::string_view key, Args &&... args) |
If a key equal to key already exists in the container, does nothing. | |
template<typename... Args> | |
iterator | try_emplace (const_iterator hint, std::string &&key, Args &&... args) |
If a key equal to key already exists in the container, does nothing. | |
template<typename... Args> | |
iterator | try_emplace (const_iterator hint, const char *key, Args &&... args) |
If a key equal to key already exists in the container, does nothing. | |
template<typename... Args> | |
iterator | try_emplace (const_iterator hint, std::string_view key, Args &&... args) |
If a key equal to key already exists in the container, does nothing. | |
iterator | erase (iterator pos) |
Removes the element at pos. | |
iterator | erase (const_iterator pos) |
Removes the element at pos. | |
iterator | erase (iterator first, iterator last) |
Removes the elements in the range [first, last), which must be a valid range in this. | |
iterator | erase (const_iterator first, const_iterator last) |
Removes the elements in the range [first, last), which must be a valid range in this. | |
size_type | erase (std::string_view key) |
Removes the element (if one exists) with the key equal to key. | |
void | swap (StringMap &other) noexcept(std::allocator_traits< Allocator >::is_always_equal::value &&std::is_nothrow_swappable< std::less<> >::value) |
Exchanges the contents of the container with those of other. | |
node_type | extract (const_iterator position) |
Unlinks the node that contains the element pointed to by position and returns a node handle that owns it. | |
node_type | extract (std::string_view key) |
If the container has an element with key equal to key, unlinks the node that contains that element from the container and returns a node handle that owns it. | |
size_type | count (std::string_view key) const |
Returns the number of elements with key that equals the specified argument. | |
iterator | find (std::string_view key) |
Finds an element with key equal to key. | |
const_iterator | find (std::string_view key) const |
Finds an element with key equal to key. | |
bool | contains (std::string_view key) const |
Checks if there is an element with key equal to key in the container. | |
std::pair< iterator, iterator > | equal_range (std::string_view key) |
Returns a range containing all elements with the given key in the container. | |
std::pair< const_iterator, const_iterator > | equal_range (std::string_view key) const |
Returns a range containing all elements with the given key in the container. | |
iterator | lower_bound (std::string_view key) |
Returns an iterator pointing to the first element that is not less than (i.e. | |
const_iterator | lower_bound (std::string_view key) const |
Returns an iterator pointing to the first element that is not less than (i.e. | |
iterator | upper_bound (std::string_view key) |
Returns an interator pointing to the first element that is greater than key. | |
const_iterator | upper_bound (std::string_view key) const |
Returns an interator pointing to the first element that is greater than key. | |
StringMap is a sorted associative container that contains key-value pairs with unique string keys.
Keys are sorted in the same order as std::string's are compared. Search, removal, and insertion operations have logarithmic complexity. The underlying implementation is std::map<std::string, T>.
using wpi::StringMap< T, Allocator >::allocator_type = typename map_type::allocator_type |
using wpi::StringMap< T, Allocator >::const_iterator = typename map_type::const_iterator |
using wpi::StringMap< T, Allocator >::const_pointer = typename map_type::const_pointer |
using wpi::StringMap< T, Allocator >::const_reference = typename map_type::const_reference |
using wpi::StringMap< T, Allocator >::const_reverse_iterator = typename map_type::const_reverse_iterator |
using wpi::StringMap< T, Allocator >::difference_type = typename map_type::difference_type |
using wpi::StringMap< T, Allocator >::insert_return_type = typename map_type::insert_return_type |
using wpi::StringMap< T, Allocator >::iterator = typename map_type::iterator |
using wpi::StringMap< T, Allocator >::key_compare = typename map_type::key_compare |
using wpi::StringMap< T, Allocator >::key_type = typename map_type::key_type |
using wpi::StringMap< T, Allocator >::map_type = typename std::map<std::string, T, std::less<>> |
using wpi::StringMap< T, Allocator >::mapped_type = typename map_type::mapped_type |
using wpi::StringMap< T, Allocator >::node_type = typename map_type::node_type |
using wpi::StringMap< T, Allocator >::pointer = typename map_type::pointer |
using wpi::StringMap< T, Allocator >::reference = typename map_type::reference |
using wpi::StringMap< T, Allocator >::reverse_iterator = typename map_type::reverse_iterator |
using wpi::StringMap< T, Allocator >::size_type = typename map_type::size_type |
using wpi::StringMap< T, Allocator >::value_type = typename map_type::value_type |
|
default |
Constructs an empty container.
|
inlineexplicit |
Constructs an empty container.
alloc | allocator to use for all memory allocations of this container |
|
inline |
Constructs the container with the contents of the range [first, last).
If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted. If [first, last) is not a valid range, the behavior is undefined.
first | start of the range to copy the elements from |
last | end of the range to copy the elements from |
alloc | allocator to use for all memory allocations of this container |
|
default |
Copy constructor.
|
inline |
Copy constructor.
other | another container to be used as source to initialize the elements of the container with |
alloc | allocator to use for all memory allocations of this container |
|
default |
Move constructor.
|
inline |
Move constructor.
other | another container to be used as source to initialize the elements of the container with |
alloc | allocator to use for all memory allocations of this container |
|
inline |
Initializer-list constructor.
Construct the container with the contents of the initializer list init. If multiple elements in the range have keys that compare equal, it is unspecified which element is inserted.
init | initializer list to initialize the elements of the container with |
alloc | allocator to use for all memory allocations of this container |
|
inline |
Returns a reference to the mapped value of the element with the specified key.
If no such element exists, an exception of type std::out_of_range is thrown.
key | the key of the element to find |
|
inline |
Returns a reference to the mapped value of the element with the specified key.
If no such element exists, an exception of type std::out_of_range is thrown.
key | the key of the element to find |
|
inline |
Returns a reference to the mapped value of the element with the specified key.
If no such element exists, an exception of type std::out_of_range is thrown.
key | the key of the element to find |
|
inline |
Returns a reference to the mapped value of the element with the specified key.
If no such element exists, an exception of type std::out_of_range is thrown.
key | the key of the element to find |
|
inline |
Returns a reference to the mapped value of the element with the specified key.
If no such element exists, an exception of type std::out_of_range is thrown.
key | the key of the element to find |
|
inline |
Returns a reference to the mapped value of the element with the specified key.
If no such element exists, an exception of type std::out_of_range is thrown.
key | the key of the element to find |
|
inline |
Checks if there is an element with key equal to key in the container.
key | key value of the element to search for |
|
inline |
Returns the number of elements with key that equals the specified argument.
key | key value of the elements to count |
|
inline |
Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.
No iterators or references are invalidated.
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.
No iterators or references are invalidated.
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.
No iterators or references are invalidated.
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
Returns a range containing all elements with the given key in the container.
The range is defined by two iterators, one pointing to the first element that is not less than key and another pointing to the first element greater than key. Alternatively, the first iterator may be obtained with lower_bound(), and the second with upper_bound().
key | key value to compare the elements to |
|
inline |
Returns a range containing all elements with the given key in the container.
The range is defined by two iterators, one pointing to the first element that is not less than key and another pointing to the first element greater than key. Alternatively, the first iterator may be obtained with lower_bound(), and the second with upper_bound().
key | key value to compare the elements to |
|
inline |
Removes the elements in the range [first, last), which must be a valid range in this.
first | Start of the range of elements to remove |
last | End of the range of elements to remove |
|
inline |
Removes the element at pos.
pos | iterator to the element to remove |
|
inline |
Removes the elements in the range [first, last), which must be a valid range in this.
first | Start of the range of elements to remove |
last | End of the range of elements to remove |
|
inline |
Removes the element at pos.
pos | iterator to the element to remove |
|
inline |
Removes the element (if one exists) with the key equal to key.
key | key value of the elements to remove |
|
inline |
Unlinks the node that contains the element pointed to by position and returns a node handle that owns it.
position | a valid iterator into this container |
|
inline |
If the container has an element with key equal to key, unlinks the node that contains that element from the container and returns a node handle that owns it.
Otherwise, returns an empty node handle.
key | a key to identify the node to be extracted |
|
inline |
Finds an element with key equal to key.
key | key value of the element to search for |
|
inline |
Finds an element with key equal to key.
key | key value of the element to search for |
|
inline |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
If the key does not exist, inserts the value as if by calling insert().
key | the key used both to look up and to insert if not found |
obj | the value to insert or assign |
|
inline |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
If the key does not exist, inserts the value as if by calling insert().
hint | iterator to the position before which the new element will be inserted |
key | the key used both to look up and to insert if not found |
obj | the value to insert or assign |
|
inline |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
If the key does not exist, inserts the value as if by calling insert().
hint | iterator to the position before which the new element will be inserted |
key | the key used both to look up and to insert if not found |
obj | the value to insert or assign |
|
inline |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
If the key does not exist, inserts the value as if by calling insert().
hint | iterator to the position before which the new element will be inserted |
key | the key used both to look up and to insert if not found |
obj | the value to insert or assign |
|
inline |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
If the key does not exist, inserts the value as if by calling insert().
key | the key used both to look up and to insert if not found |
obj | the value to insert or assign |
|
inline |
If a key equal to key already exists in the container, assigns obj to the mapped type corresponding to that key.
If the key does not exist, inserts the value as if by calling insert().
key | the key used both to look up and to insert if not found |
obj | the value to insert or assign |
|
inline |
Returns an iterator pointing to the first element that is not less than (i.e.
greater or equal to) key.
key | key value to compare the elements to |
|
inline |
Returns an iterator pointing to the first element that is not less than (i.e.
greater or equal to) key.
key | key value to compare the elements to |
|
default |
Copy assignment operator.
|
inline |
Replaces the contents with those identified by initializer list ilist.
ilist | initializer list to use as data source |
|
defaultnoexcept |
Move assignment operator.
|
inline |
Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.
key | the key of the element to find |
|
inline |
Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.
key | the key of the element to find |
|
inline |
Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.
key | the key of the element to find |
|
inline |
Returns a reference to the value that is mapped to a key, performing an insertion if such a key does not exist.
key | the key of the element to find |
|
inlinenoexcept |
Exchanges the contents of the container with those of other.
Does not invoke any move, copy, or swap operations on individual elements.
All iterators and references remain valid. The end() iterator is invalidated.
other | container to exchange the contents with |
|
inline |
If a key equal to key already exists in the container, does nothing.
Otherwise, inserts a new element into the container with key key and value constructed with args.
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
If a key equal to key already exists in the container, does nothing.
Otherwise, inserts a new element into the container with key key and value constructed with args.
hint | iterator to the position before which the new element will be inserted |
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
If a key equal to key already exists in the container, does nothing.
Otherwise, inserts a new element into the container with key key and value constructed with args.
hint | iterator to the position before which the new element will be inserted |
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
If a key equal to key already exists in the container, does nothing.
Otherwise, inserts a new element into the container with key key and value constructed with args.
hint | iterator to the position before which the new element will be inserted |
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
If a key equal to key already exists in the container, does nothing.
Otherwise, inserts a new element into the container with key key and value constructed with args.
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
If a key equal to key already exists in the container, does nothing.
Otherwise, inserts a new element into the container with key key and value constructed with args.
key | the key used both to look up and to insert if not found |
args | arguments to forward to the constructor of the element |
|
inline |
Returns an interator pointing to the first element that is greater than key.
key | key value to compare the elements to |
|
inline |
Returns an interator pointing to the first element that is greater than key.
key | key value to compare the elements to |