Represents a collection of keys and values.
The example uses the xtd::collections::generic::dictionary::operator [] to retrieve values, demonstrating that a xtd::collections::generic::key_not_found_exception is thrown when a requested key is not present, and showing that the value associated with a key can be replaced.
The example shows how to use the xtd::collections::generic::dictionary::try_get_vValue method as a more efficient way to retrieve values if a program often must try key values that are not in the dictionary, and it shows how to use the xtd::collections::generic::dictionary::contains_key method to test whether a key exists before calling the xtd::collections::generic::dictionary::add method.
The example shows how to enumerate the keys and values in the dictionary and how to enumerate the keys and values alone using the xtd::collections::generic::dictionary::keys property and the xtd::collections::generic::dictionary::values property.
Finally, the example demonstrates the xtd::collections::generic::dictionary::remove method.
key_t
. key_t
implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation. auto
key type and the value type. For example: Classes | |
struct | equator |
Represents the dictionary equator type. More... | |
struct | hasher |
Represents the dictionary hasher type. More... | |
Public Aliases | |
using | key_type = typename xtd::collections::generic::idictionary< key_t, value_t >::key_type |
Represents the dictionary key type. | |
using | mapped_type = typename xtd::collections::generic::idictionary< key_t, value_t >::mapped_type |
Represents the dictionary mapped type. | |
using | value_type = typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_type |
Represents the dictionary value type. | |
using | size_type = xtd::size |
Represents the dictionary size type. | |
using | difference_type = xtd::ptrdiff |
Represents the dictionary difference type. | |
using | key_equal = equator |
Represents the dictionary key_equal type. | |
using | allocator_type = allocator_t |
Represents the dictionary allocator type. | |
using | base_value_type = std::pair< const key_t, value_t > |
Represents the dictionary base value type. | |
using | base_type = std::unordered_map< key_type, mapped_type, hasher, key_equal, allocator_type > |
Represents the dictionary base type. | |
using | reference = value_type & |
Represents the dictionary reference type. | |
using | const_reference = const value_type & |
Represents the dictionary const reference type. | |
using | pointer = typename std::allocator_traits< allocator_t >::pointer |
Represents the dictionary pointer type. | |
using | const_pointer = typename std::allocator_traits< allocator_t >::const_pointer |
Represents the dictionary const pointer type. | |
using | iterator = typename xtd::collections::generic::idictionary< key_type, mapped_type >::iterator |
Represents the iterator of dictionary value type. | |
using | const_iterator = typename xtd::collections::generic::idictionary< key_type, mapped_type >::const_iterator |
Represents the const iterator of dictionary value type. | |
using | local_iterator = typename base_type::local_iterator |
Represents the local iterator of dictionary value type. | |
using | const_local_iterator = typename base_type::const_local_iterator |
Represents the const local iterator of dictionary value type. | |
using | node_type = typename base_type::node_type |
Represents the dictionary node type. | |
using | insert_return_type = typename base_type::insert_return_type |
Represents the dictionary insert return type. | |
using | key_collection = typename xtd::collections::generic::idictionary< key_type, mapped_type >::key_collection |
Represents the idictionary key collection type. | |
using | value_collection = typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_collection |
Represents the idictionary value collection type. | |
Public Constructors | |
dictionary () noexcept=default | |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the default initial capacity, and uses the default equality comparer for the key type. | |
dictionary (const idictionary< key_t, value_t > &dictionary) | |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::idictionary <key_t, value_t> and uses the default equality comparer for the key type. | |
dictionary (const ienumerable< value_type > &collection) | |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::ienumerable <type_t>. | |
template<class equality_comparer_t > | |
dictionary (const equality_comparer_t &comparer) | |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the default initial capacity, and uses the specified xtd::collections::generic::iequality_comparer<type_t>. | |
dictionary (size_type bucket_count, const hasher_t &hash=hasher_t {}, const equator_t &equal=equator_t {}, const allocator_type &alloc=allocator_type {}) noexcept | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (size_type bucket_count, const hasher_t &hash, const allocator_type &alloc) noexcept | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
template<class equality_comparer_t > | |
dictionary (const idictionary< key_t, value_t > &dictionary, const equality_comparer_t &comparer) | |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::dictionary <key_t, value_t> and uses the specified xtd::collections::generic::iequality_comparer <type_t>. | |
template<class equality_comparer_t > | |
dictionary (const ienumerable< value_type > &collection, const equality_comparer_t &comparer) | |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::ienumerable <type_t> and uses the specified xtd::collections::generic::iequality_comparer <type_t>. | |
template<class equality_comparer_t > | |
dictionary (size_t capacity, const equality_comparer_t &comparer) | |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the specified initial capacity, and uses the specified xtd::collections::generic::iequality_comparer <type_t>. | |
template<class input_iterator_t > | |
dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count=0, const hasher_t &hash=hasher_t {}, const equator_t &equal=equator_t {}, const allocator_type &alloc=allocator_type {}) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
template<class input_iterator_t > | |
dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count, const allocator_type &alloc) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
template<class input_iterator_t > | |
dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count, const hasher_t &hash, const allocator_type &alloc) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (const dictionary &other) noexcept | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (const std::unordered_map< key_t, value_t > &other) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (const std::unordered_map< key_t, value_t > &other, const allocator_type &alloc) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (dictionary &&other) noexcept=default | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (dictionary &&other, const allocator_type &alloc) noexcept | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (std::unordered_map< key_t, value_t > &&other) noexcept | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (std::unordered_map< key_t, value_t > &&other, const allocator_type &alloc) noexcept | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (std::initializer_list< base_value_type > init, size_type bucket_count=0, const hasher_t &hash=hasher_t {}, const equator_t &equal=equator_t {}, const allocator_type &alloc=allocator_type {}) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (std::initializer_list< base_value_type > init, size_type bucket_count, const allocator_type &alloc) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
dictionary (std::initializer_list< base_value_type > init, size_type bucket_count, const hasher_t &hash, const allocator_type &alloc) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
template<class init_key_t , class init_value_t > | |
dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init, size_type bucket_count=0, const hasher_t &hash=hasher_t {}, const equator_t &equal=equator_t {}, const allocator_type &alloc=allocator_type {}) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
template<class init_key_t , class init_value_t > | |
dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init, size_type bucket_count, const allocator_type &alloc) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
template<class init_key_t , class init_value_t > | |
dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init, size_type bucket_count, const hasher_t &hash, const allocator_type &alloc) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator. | |
Public Properties | |
const_iterator | begin () const noexcept override |
Returns an iterator to the first element of the enumarable. | |
iterator | begin () noexcept override |
Returns an iterator to the first element of the enumarable. | |
size_type | bucket_count () const noexcept |
Gets the number of buckets in the container. | |
size_type | capacity () const noexcept |
Gets the total numbers of elements the internal data structure can hold without resizing. | |
const_iterator | cbegin () const noexcept override |
Returns an iterator to the first element of the enumarable. | |
const_iterator | cend () const noexcept override |
Returns an iterator to the element following the last element of the enumarable. | |
const iequality_comparer< key_t > & | comparer () const noexcept |
Gets the td::collections::generic::iequality_comparer <type_t> that is used to determine equality of keys for the dictionary. | |
size_type | count () const noexcept override |
Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>. | |
bool | empty () const noexcept |
Checks if the container has no elements, i.e. whether begin() == end() . | |
const_iterator | end () const noexcept override |
Returns an iterator to the element following the last element of the enumarable. | |
iterator | end () noexcept override |
Returns an iterator to the element following the last element of the enumarable. | |
bool | is_read_only () const noexcept override |
Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only. | |
bool | is_synchronized () const noexcept override |
Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe). | |
virtual const base_type & | items () const noexcept |
Returns the underlying base type items. | |
virtual base_type & | items () noexcept |
Returns the underlying base type items. | |
key_collection | keys () const noexcept override |
Gets a collection containing the keys in the xtd::collections::generic::dictionary <key_t, value_t>. | |
float | load_factor () const |
Gets the average number of elements per bucket, that is, xtd::collections::generic::dictionary::size divided by xtd::collections::generic::dictionary::bucket_count. | |
size_type | max_bucket_count () const noexcept |
Gets the maximum number of buckets the container is able to hold due to system or library implementation limitations. | |
float | max_load_factor () const |
Gets the maximum load factor (number of elements per bucket). The container automatically increases the number of buckets if the load factor exceeds this threshold. | |
void | max_load_factor (float value) const |
Sets the maximum load factor (number of elements per bucket). The container automatically increases the number of buckets if the load factor exceeds this threshold. | |
size_type | max_size () const noexcept |
Gets the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. std::distance(begin(), end()) for the largest container. | |
size_type | size () const noexcept |
Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>. | |
const xtd::object & | sync_root () const noexcept override |
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>. | |
value_collection | values () const noexcept override |
Gets a collection containing the values in the xtd::collections::generic::dictionary <key_t, value_t>. | |
Public Methods | |
void | add (const key_t &key, const value_t value) override |
Adds an element with the provided key and value to the xtd::collections::generic::dictionary <key_t, value_t>. | |
void | add (const value_type &item) override |
Adds an item to the xtd::collections::generic::icollection <type_t>. | |
const value_t & | at (const key_t &key) const |
Gets the element with the specified key. | |
value_t & | at (const key_t &key) |
Gets the element with the specified key. | |
local_iterator | begin (size_type n) |
Returns an iterator to the beginning of the specified bucket. | |
const_local_iterator | begin (size_type n) const |
Returns an iterator to the beginning of the specified bucket. | |
size_type | bucket (const key_t &key) const |
Returns the index of the bucket for key key. Elements (if any) with keys equivalent to key are always found in this bucket. | |
size_type | bucket_size (size_type n) const noexcept |
Returns the number of elements in the bucket with index n . | |
const_local_iterator | cbegin (size_type n) const |
Returns an iterator to the beginning of the specified bucket. | |
const_local_iterator | cend (size_type n) const |
Returns an iterator to the end of the specified bucket. | |
void | clear () noexcept override |
Removes all keys and values from the xtd::collections::generic::dictionary <key_t, value_t>. | |
bool | contains (const key_t &key) const noexcept |
Checks if the container contains element with specific key. | |
template<class contains_key_t > | |
bool | contains (const contains_key_t &x) const |
Checks if the container contains element with specific key. | |
bool | contains (const value_type &item) const noexcept override |
Determines whether an element is in the xtd::collections::generic::dictionary <key_t, value_t>. | |
bool | contains_key (const key_t &key) const noexcept override |
Determines whether the xtd::collections::generic::dictionary <key_t, value_t> contains the specified key. | |
bool | contains_value (const value_t &value) const noexcept |
void | copy_to (xtd::array< value_type > &array, xtd::size array_index) const override |
Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index. | |
template<class ... args_t> | |
key_value_pair< iterator, bool > | emplace (args_t &&...args) |
Constructs element in-place. | |
template<class ... args_t> | |
iterator | emplace_hint (iterator hint, args_t &&...args) |
constructs elements in-place using a hint | |
local_iterator | end (size_type n) |
Returns an iterator to the end of the specified bucket. | |
const_local_iterator | end (size_type n) const |
Returns an iterator to the end of the specified bucket. | |
xtd::size | ensure_capacity (xtd::size capacity) noexcept |
Ensures that the dictionary can hold up to a specified number of entries without any further expansion of its backing storage. | |
key_value_pair< iterator, iterator > | equal_range (const key_t &key) |
Returns range of elements matching a specific key. | |
template<class equal_range_key_t > | |
key_value_pair< const_iterator, const_iterator > | equal_range (const equal_range_key_t &key) const |
Returns range of elements matching a specific key. | |
template<class equal_range_key_t > | |
key_value_pair< iterator, iterator > | equal_range (const equal_range_key_t &x) |
Returns range of elements matching a specific key. | |
key_value_pair< const_iterator, const_iterator > | equal_range (const key_t &x) const |
Returns range of elements matching a specific key. | |
iterator | erase (const_iterator pos) |
Erases elements. | |
iterator | erase (const_iterator first, const_iterator last) |
Erases elements. | |
size_type | erase (const key_t &key) |
Erases elements. | |
node_type | extract (const_iterator position) noexcept |
Extracts nodes from the container. | |
node_type | extract (const key_t k) |
Extracts nodes from the container. | |
const_iterator | find (const key_t &key) const |
Finds element with specific key. | |
const_iterator | find (const key_t &key) |
Finds element with specific key. | |
template<class find_key_t > | |
const_iterator | find (const find_key_t &x) const |
Finds element with specific key. | |
template<class find_key_t > | |
iterator | find (const find_key_t &x) |
Finds element with specific key. | |
allocator_type | get_allocator () const noexcept |
Returns the allocator associated with the container. | |
enumerator< value_type > | get_enumerator () const noexcept override |
Returns an enumerator that iterates through the xtd::collections::generic::dictionary <key_t, value_t>. | |
hasher | hash_function () const |
Returns function used to hash the keys. | |
key_value_pair< iterator, bool > | insert (const value_type &value) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
key_value_pair< iterator, bool > | insert (value_type &&value) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
template<class type_t > | |
key_value_pair< iterator, bool > | insert (type_t &&value) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
iterator | insert (const_iterator hint, const value_type &value) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
iterator | insert (const_iterator hint, value_type &&value) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
template<class type_t > | |
iterator | insert (const_iterator hint, type_t &&value) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
template<class input_iterator_t > | |
void | insert (input_iterator_t first, input_iterator_t last) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
void | insert (std::initializer_list< base_value_type > ilist) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
template<class init_key_t , class init_value_t > | |
void | insert (std::initializer_list< key_value_pair< init_key_t, init_value_t > > ilist) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
insert_return_type | insert (node_type &&nh) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
iterator | insert (const_iterator hint, node_type &&nh) |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key. | |
template<class type_t > | |
key_value_pair< iterator, bool > | insert_or_assign (const key_t &k, type_t &&obj) |
Inserts an element or assigns to the current element if the key already exists. | |
template<class type_t > | |
key_value_pair< iterator, bool > | insert_or_assign (key_t &&k, type_t &&obj) |
Inserts an element or assigns to the current element if the key already exists. | |
template<class type_t > | |
iterator | insert_or_assign (const_iterator hint, const key_t &k, type_t &&obj) |
Inserts an element or assigns to the current element if the key already exists. | |
template<class type_t > | |
iterator | insert_or_assign (const_iterator hint, key_t &&k, type_t &&obj) |
Inserts an element or assigns to the current element if the key already exists. | |
key_equal | key_eq () const |
Returns the function used to compare keys for equality. | |
template<class source_hasher_t , class source_equator_t > | |
void | merge (dictionary< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source) |
Splices nodes from another container. | |
template<class source_hasher_t , class source_equator_t > | |
void | merge (dictionary< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source) |
Splices nodes from another container. | |
template<class source_hasher_t , class source_equator_t > | |
void | merge (std::unordered_map< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source) |
Splices nodes from another container. | |
template<class source_hasher_t , class source_equator_t > | |
void | merge (std::unordered_map< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source) |
Splices nodes from another container. | |
template<class source_hasher_t , class source_equator_t > | |
void | merge (std::unordered_multimap< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source) |
Splices nodes from another container. | |
template<class source_hasher_t , class source_equator_t > | |
void | merge (std::unordered_multimap< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source) |
Splices nodes from another container. | |
void | rehash (size_type count) |
Reserves at least the specified number of buckets and regenerates the hash table. | |
bool | remove (const key_t &key) noexcept override |
Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t, value_t>. | |
bool | remove (const value_type &item) noexcept override |
Removes the first occurrence of a specific object from the xtd::collections::generic::dictionary <key_t, value_t>. | |
bool | remove (const key_t &key, value_t &value) noexcept |
Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t, value_t>, and copies the element to the value parameter. | |
void | reserve (size_type count) |
Reserves space for at least the specified number of elements and regenerates the hash table. | |
void | swap (dictionary &other) noexcept |
Swaps the contents. | |
xtd::string | to_string () const noexcept override |
Gets a string that represents the current object. | |
void | trim_excess (size_type capacity) |
Sets the capacity of this dictionary to hold up a specified number of entries without any further expansion of its backing storage. | |
void | trim_excess () |
Sets the capacity of this dictionary to what it would be if it had been originally initialized with all its entries. | |
bool | try_add (const key_t &key, const value_t value) noexcept |
Attempts to add the specified key and value to the dictionary. | |
template<class ... args_t> | |
key_value_pair< iterator, bool > | try_emplace (const key_t &k, args_t &&... args) |
Inserts in-place if the key does not exist, does nothing if the key exists. | |
template<class ... args_t> | |
key_value_pair< iterator, bool > | try_emplace (key_t &&k, args_t &&... args) |
Inserts in-place if the key does not exist, does nothing if the key exists. | |
template<class ... args_t> | |
iterator | try_emplace (const_iterator hint, const key_t &k, args_t &&... args) |
Inserts in-place if the key does not exist, does nothing if the key exists. | |
template<class ... args_t> | |
iterator | try_emplace (const_iterator hint, key_t &&k, args_t &&... args) |
Inserts in-place if the key does not exist, does nothing if the key exists. | |
bool | try_get_value (const key_t &key, value_t &value) const override |
Gets the value associated with the specified key. | |
Public Operators | |
dictionary & | operator= (dictionary &&other) noexcept |
Move assignment operator. Replaces the contents with a copy of the contents of other . | |
dictionary & | operator= (std::unordered_map< key_t, value_t > &&other) noexcept |
Move assignment operator. Replaces the contents with a copy of the contents of other . | |
dictionary & | operator= (const dictionary &other) noexcept=default |
Copy assignment operator. Replaces the contents with a copy of the contents of other . | |
dictionary & | operator= (const std::unordered_map< key_t, value_t > &other) noexcept |
Copy assignment operator. Replaces the contents with a copy of the contents of other . | |
dictionary & | operator= (std::initializer_list< base_value_type > ilist) |
Copy assignment operator. Replaces the contents with a copy of the contents of other . | |
template<class init_key_t , class init_value_t > | |
dictionary & | operator= (std::initializer_list< key_value_pair< init_key_t, init_value_t > > ilist) |
Copy assignment operator. Replaces the contents with a copy of the contents of other . | |
const value_t & | operator[] (const key_t &key) const override |
Gets the element with the specified key. | |
value_t & | operator[] (const key_t &key) override |
Sets the element with the specified key. | |
operator const base_type & () const noexcept | |
Returns a reference to the underlying base type. | |
operator base_type & () noexcept | |
Returns a reference to the underlying base type. | |
Additional Inherited Members | |
![]() | |
using | key_type = key_t |
Represents the dictionary key type. | |
using | mapped_type = value_t |
Represents the dictionary mapped type. | |
using | value_type = typename xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >::value_type |
Represents the xtd::collections::generic::idictionary value type. | |
using | iterator = typename xtd::collections::generic::icollection< value_type >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator = typename xtd::collections::generic::icollection< value_type >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
using | key_collection = xtd::collections::generic::list< key_type > |
Represents the idictionary key collection type. | |
using | value_collection = xtd::collections::generic::list< mapped_type > |
Represents the idictionary value collection type. | |
![]() | |
using | value_type = typename xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > >::value_type |
Represents the xtd::collections::generic::icollection value type. | |
using | iterator = typename xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator = typename xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
![]() | |
using | value_type = type_t |
Represents the xtd::collections::generic::ienumerable value type. | |
using | iterator = typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator = typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
![]() | |
using | iterator = enumerable_iterator |
Represents the iterator of enumarable value type. | |
using | const_iterator = const enumerable_iterator |
Represents the const iterator of enumarable value type. | |
![]() | |
using | enumerable_type = ienumerable< type_t > |
Represents the ienumerable enumerable type. | |
using | source_type = type_t |
Represents the ienumerable source type. | |
using | ienumerable = typename xtd::linq::enumerable::ienumerable< type_t > |
Represents the ienumerable value type. | |
using | list = typename xtd::linq::enumerable::list< type_t > |
Represents the list value type. | |
![]() | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual xtd::size | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<class object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
![]() | |
![]() | |
virtual void | add (const xtd::collections::generic::key_value_pair< key_t, value_t > &item)=0 |
Adds an item to the xtd::collections::generic::icollection <type_t>. | |
virtual bool | contains (const xtd::collections::generic::key_value_pair< key_t, value_t > &item) const noexcept=0 |
Determines whether the xtd::collections::generic::icollection <type_t> contains a specific value. | |
virtual void | copy_to (xtd::array< xtd::collections::generic::key_value_pair< key_t, value_t > > &array, xtd::size array_index) const=0 |
Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index. | |
virtual bool | remove (const xtd::collections::generic::key_value_pair< key_t, value_t > &item)=0 |
Removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>. | |
![]() | |
![]() | |
![]() | |
type_t | aggregate (const std::function< type_t(const type_t &, const type_t &)> &func) const |
Applies an accumulator function over a sequence. | |
type_t | aggregate (const type_t &seed, const std::function< type_t(const type_t &, const type_t &)> &func) const |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value. | |
accumulate_t | aggregate (const accumulate_t &seed, const std::function< accumulate_t(const type_t &, const accumulate_t &)> &func) const |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value. | |
type_t | aggregate (const type_t &seed, const std::function< type_t(const type_t &, const type_t &)> &func, const std::function< type_t(const type_t &)> &result_selector) const |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value. | |
result_t | aggregate (const accumulate_t &seed, const std::function< accumulate_t(const type_t &, const accumulate_t &)> &func, const std::function< result_t(const accumulate_t &)> &result_selector) const |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value. | |
bool | all (const std::function< bool(const type_t &)> &predicate) const |
Determines whether all elements of a sequence satisfy a condition. | |
bool | any () const noexcept |
Determines whether a sequence contains any elements. | |
bool | any (const std::function< bool(const type_t &)> &predicate) const |
Determines whether any element of a sequence satisfies a condition. | |
const ienumerable< type_t > & | append (const type_t &element) const noexcept |
Appends a value to the end of the sequence. | |
const ienumerable< type_t > & | as_enumerable () const noexcept |
Returns the input typed as xtd::collection::generic::ienumerable <type_t>. | |
auto | average () const noexcept |
Computes the average of a sequence of source_t values. | |
const ienumerable< result_t > & | cast () const noexcept |
Casts the elements of an xtd::collection::generic::ienumerable to the specified type. | |
const ienumerable< xtd::array< type_t > > & | chunk (size_t size) const |
Splits the elements of a sequence into chunks of size at most size. | |
const ienumerable< type_t > & | concat (const ienumerable< type_t > &second) const noexcept |
Concatenates two sequences. | |
bool | contains (const type_t &value) const noexcept |
Determines whether a sequence contains a specified element by using the default equality comparer. | |
bool | contains (const type_t &value, const xtd::collections::generic::iequality_comparer< type_t > &comparer) const noexcept |
Determines whether a sequence contains a specified element by using a specified equality comparer. | |
size_t | count () const noexcept |
Returns the number of elements in current sequence. | |
size_t | count (const std::function< bool(const type_t &)> &predicate) const noexcept |
Returns a number that represents how many elements in the specified sequence satisfy a condition. | |
const ienumerable< key_value_pair< key_t, xtd::size > > & | count_by (const std::function< key_t(const type_t &)> &key_selector) const noexcept |
Returns the count of elements in the current sequence grouped by key. | |
const ienumerable< key_value_pair< key_t, xtd::size > > & | count_by (const std::function< key_t(const type_t &)> &key_selector, const iequality_comparer< key_t > &key_comparer) const noexcept |
Returns the count of elements in the current sequence grouped by key. | |
const ienumerable< type_t > & | default_if_empty () const noexcept |
Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty. | |
const ienumerable< type_t > & | default_if_empty (const type_t &default_value) const noexcept |
Returns the elements of the specified sequence or the specified value in a singleton collection if the current sequence is empty. | |
type_t | first_or_default (const std::function< bool(const type_t &)> &predicate, const type_t &default_value) const noexcept |
Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found. | |
type_t | first_or_default (const std::function< bool(const type_t &)> &predicate) const noexcept |
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. | |
type_t | first_or_default (const type_t default_value) const noexcept |
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. | |
type_t | first_or_default () const noexcept |
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. | |
const ienumerable< result_t > & | select (const std::function< result_t(const type_t &)> &selector) const |
Projects each element of a sequence into a new form. | |
const ienumerable< type_t > & | select (const std::function< type_t(const type_t &)> &selector) const |
Projects each element of a sequence into a new form. | |
const ienumerable< result_t > & | select (const std::function< result_t(const type_t &, size_t index)> &selector) const |
Projects each element of a sequence into a new form by incorporating the element's index. | |
const ienumerable< type_t > & | select (const std::function< type_t(const type_t &, size_t index)> &selector) const |
Projects each element of a sequence into a new form by incorporating the element's index. | |
const list< type_t > & | to_list () const noexcept |
Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>. | |
const ienumerable< type_t > & | where (const std::function< bool(const type_t &)> &predicate) const |
Filters a sequence of values based on a predicate. | |
const ienumerable< type_t > & | where (const std::function< bool(const type_t &, size_t)> &predicate) const |
Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function. | |
![]() | |
virtual collection_t & | operator<< (const type_t &item) |
The shift left operator adds an item to the xtd::collections::generic::icollection <type_t>. | |
virtual collection_t & | operator>> (const type_t &item) |
The shift right operator removes tthe first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>. | |
![]() | |
template<class object_a_t , class object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<class object_a_t , class object_b_t > | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
![]() | |
static target_collection_t::const_iterator | to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept |
Converts source iterator to target iterator. | |
static target_collection_t::iterator | to_iterator (typename source_collection_t::iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept |
Converts source iterator to target iterator. | |
static target_collection_t::const_iterator | to_iterator (typename source_collection_t::const_iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept |
Converts source iterator to target iterator. | |
static target_collection_t::iterator | to_iterator (typename source_collection_t::iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept |
Converts source iterator to target iterator. | |
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::key_type = typename xtd::collections::generic::idictionary<key_t, value_t>::key_type |
Represents the dictionary key type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::mapped_type = typename xtd::collections::generic::idictionary<key_t, value_t>::mapped_type |
Represents the dictionary mapped type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::value_type = typename xtd::collections::generic::idictionary<key_type, mapped_type>::value_type |
Represents the dictionary value type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::size_type = xtd::size |
Represents the dictionary size type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::difference_type = xtd::ptrdiff |
Represents the dictionary difference type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::key_equal = equator |
Represents the dictionary key_equal type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::allocator_type = allocator_t |
Represents the dictionary allocator type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::base_value_type = std::pair<const key_t, value_t> |
Represents the dictionary base value type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::base_type = std::unordered_map<key_type, mapped_type, hasher, key_equal, allocator_type> |
Represents the dictionary base type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::reference = value_type& |
Represents the dictionary reference type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::const_reference = const value_type& |
Represents the dictionary const reference type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::pointer = typename std::allocator_traits<allocator_t>::pointer |
Represents the dictionary pointer type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::const_pointer = typename std::allocator_traits<allocator_t>::const_pointer |
Represents the dictionary const pointer type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::iterator = typename xtd::collections::generic::idictionary<key_type, mapped_type>::iterator |
Represents the iterator of dictionary value type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::const_iterator = typename xtd::collections::generic::idictionary<key_type, mapped_type>::const_iterator |
Represents the const iterator of dictionary value type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::local_iterator = typename base_type::local_iterator |
Represents the local iterator of dictionary value type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::const_local_iterator = typename base_type::const_local_iterator |
Represents the const local iterator of dictionary value type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::node_type = typename base_type::node_type |
Represents the dictionary node type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert_return_type = typename base_type::insert_return_type |
Represents the dictionary insert return type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::key_collection = typename xtd::collections::generic::idictionary<key_type, mapped_type>::key_collection |
Represents the idictionary key collection type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::value_collection = typename xtd::collections::generic::idictionary<key_type, mapped_type>::value_collection |
Represents the idictionary value collection type.
|
defaultnoexcept |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the default initial capacity, and uses the default equality comparer for the key type.
key_t
implements the xtd::equatable <type_t> generic interface, the default equality comparer uses that implementation. Alternatively, you can specify an implementation of the iequality_comparer <typer_t> generic interface by using a constructor that accepts a comparer parameter. This code example is part of a larger example provided for the xtd::collections::generic::dictionary <key_t, value_t> class.
|
inline |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::idictionary <key_t, value_t> and uses the default equality comparer for the key type.
dictionary | The xtd::collections::generic::idictionary <key_t, value_t> whose elements are copied to the new xtd::collections::generic::dictionary <key_t, value_t>. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
dictionary
must also be unique according to the default equality comparer. key_t
implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation. Alternatively, you can specify an implementation of the xtd::collections::generic::iequality_comparer <type_t> generic interface by using a constructor that accepts a comparer parameter.
|
inline |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::ienumerable <type_t>.
collection | The xtd::collections::generic::ienumerable <type_t> whose elements are copied to the new xtd::collections::generic::dictionary <key_t, value_t> |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inline |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the default initial capacity, and uses the specified xtd::collections::generic::iequality_comparer<type_t>.
comparer | The xtd::collections::generic::iequality_comparer<type_t> implementation to use when comparing keys. |
key_t
implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
|
inlineexplicitnoexcept |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
hash | Hash function to use. |
equal | Comparison function to use for all key comparisons of this container. |
alloc | Allocator to use for all memory allocations of this container. |
key_t
implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
|
inlinenoexcept |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
hash | Hash function to use. |
alloc | Allocator to use for all memory allocations of this container. |
key_t
implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
|
inline |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::dictionary <key_t, value_t> and uses the specified xtd::collections::generic::iequality_comparer <type_t>.
dictionary | The xtd::collections::generic::dictionary <key_t, value_t> whose elements are copied to the new xtd::collections::generic::dictionary <key_t, value_t>. |
comparer | The xtd::collections::generic::iequality_comparer <type_t> implementation to use when comparing keys. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
dictionary
must also be unique according to the specified comparer. comparer
is one of the case-insensitive string comparers provided by the xtd::string_comparer class and dictionary
does not use a case-insensitive comparer key. dictionary
. key_t
implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
|
inline |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::ienumerable <type_t> and uses the specified xtd::collections::generic::iequality_comparer <type_t>.
collection | The xtd::collections::generic::ienumerable <type_t> whose elements are copied to the new xtd::collections::generic::dictionary <key_t, value_t>. |
comparer | The xtd::collections::generic::iequality_comparer <type_t> implementation to use when comparing keys. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inline |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the specified initial capacity, and uses the specified xtd::collections::generic::iequality_comparer <type_t>.
capacity | The initial number of elements that the xtd::collections::generic::dictionary <key_t, value_t> can contain. |
comparer | The xtd::collections::generic::iequality_comparer <type_t> implementation to use when comparing keys. |
dictionary
must also be unique according to the specified comparer.
|
inlineexplicit |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
first | The fist iterator of the range [first, last) to copy the elements from. |
last | Thaae last itezrator of the range [first, last) to copy the elements from. |
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
hash | Hash function to use. |
equal | Comparison function to use for all key comparisons of this container. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
1.0
. If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844.
|
inlineexplicit |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
first | The fist iterator of the range [first, last) to copy the elements from. |
last | Thaae last itezrator of the range [first, last) to copy the elements from. |
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
1.0
. If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844.
|
inlineexplicit |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
first | The fist iterator of the range [first, last) to copy the elements from. |
last | Thaae last itezrator of the range [first, last) to copy the elements from. |
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
hash | Hash function to use. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
1.0
. If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844.
|
inlinenoexcept |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
other | Another container to be used as source to initialize the elements of the container with. |
other
, copies the load factor, the predicate, and the hash function as well. If alloc
is not provided, allocator is obtained by calling
|
inline |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
other | Another container to be used as source to initialize the elements of the container with. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
other
, copies the load factor, the predicate, and the hash function as well. If alloc
is not provided, allocator is obtained by calling
|
inline |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
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. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
other
, copies the load factor, the predicate, and the hash function as well. If alloc
is not provided, allocator is obtained by calling
|
defaultnoexcept |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
other | Another container to be used as source to initialize the elements of the container with. |
other
using move semantics. If alloc
is not provided, allocator is obtained by move-construction from the allocator belonging to other.
|
inlinenoexcept |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
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. |
other
using move semantics. If alloc
is not provided, allocator is obtained by move-construction from the allocator belonging to other.
|
inlinenoexcept |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
other | Another container to be used as source to initialize the elements of the container with. |
other
using move semantics. If alloc
is not provided, allocator is obtained by move-construction from the allocator belonging to other.
|
inlinenoexcept |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
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. |
other
using move semantics. If alloc
is not provided, allocator is obtained by move-construction from the allocator belonging to other.
|
inlineexplicit |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
init | Initializer list to initialize the elements of the container with. |
hash | Hash function to use. |
equal | Comparison function to use for all key comparisons of this container. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inline |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
init | Initializer list to initialize the elements of the container with. |
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inline |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
init | Initializer list to initialize the elements of the container with. |
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
hash | Hash function to use. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inlineexplicit |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
init | Initializer list to initialize the elements of the container with. |
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
hash | Hash function to use. |
equal | Comparison function to use for all key comparisons of this container. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inline |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
init | Initializer list to initialize the elements of the container with. |
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inline |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count
as a minimal number of buckets to create, hash
as the hash function, equal
as the function to compare keys and alloc
as the allocator.
init | Initializer list to initialize the elements of the container with. |
bucket_count | Minimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used. |
hash | Hash function to use. |
alloc | Allocator to use for all memory allocations of this container. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inlineoverridevirtualnoexcept |
Returns an iterator to the first element of the enumarable.
Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >.
|
inlineoverridevirtualnoexcept |
Returns an iterator to the first element of the enumarable.
Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >.
|
inlinenoexcept |
Gets the number of buckets in the container.
|
inlinenoexcept |
Gets the total numbers of elements the internal data structure can hold without resizing.
|
inlineoverridevirtualnoexcept |
Returns an iterator to the first element of the enumarable.
Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >.
|
inlineoverridevirtualnoexcept |
Returns an iterator to the element following the last element of the enumarable.
Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >.
|
inlinenoexcept |
Gets the td::collections::generic::iequality_comparer <type_t> that is used to determine equality of keys for the dictionary.
|
inlineoverridevirtualnoexcept |
Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>.
Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.
|
inlinenoexcept |
|
inlineoverridevirtualnoexcept |
Returns an iterator to the element following the last element of the enumarable.
Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >.
|
inlineoverridevirtualnoexcept |
Returns an iterator to the element following the last element of the enumarable.
Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >.
|
inlineoverridevirtualnoexcept |
Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
true
if the xtd::collections::generic::icollection <type_t> is read-only; otherwise, false
. true
, even though individual array elements can be modified. Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.
|
inlineoverridevirtualnoexcept |
Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe).
true
if access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe); otherwise, false
. synchronized
method, which provides a synchronized wrapper around the underlying collection. Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.
|
inlinevirtualnoexcept |
Returns the underlying base type items.
|
inlinevirtualnoexcept |
Returns the underlying base type items.
|
inlineoverridevirtualnoexcept |
Gets a collection containing the keys in the xtd::collections::generic::dictionary <key_t, value_t>.
Implements xtd::collections::generic::idictionary< key_t, value_t >.
|
inline |
Gets the average number of elements per bucket, that is, xtd::collections::generic::dictionary::size divided by xtd::collections::generic::dictionary::bucket_count.
|
inlinenoexcept |
Gets the maximum number of buckets the container is able to hold due to system or library implementation limitations.
|
inline |
Gets the maximum load factor (number of elements per bucket). The container automatically increases the number of buckets if the load factor exceeds this threshold.
|
inline |
Sets the maximum load factor (number of elements per bucket). The container automatically increases the number of buckets if the load factor exceeds this threshold.
value | The new maximum load factor setting. |
|
inlinenoexcept |
Gets the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. std::distance(begin(), end())
for the largest container.
xtd::ptrdiff_object::max_value
or std::numeric_limits<difference_type>::max()
. At runtime, the size of the container may be limited to a value smaller than max_size() by the amount of RAM available.
|
inlinenoexcept |
Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>.
|
inlineoverridevirtualnoexcept |
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.
sync_root
property. synchronized
method, which provides a synchronized wrapper around the underlying collection. However, derived classes can provide their own synchronized version of the collection using the xtd::collections::generic::icollection::sync_root property. The synchronizing code must perform operations on the xtd::collections::generic::icollection::sync_root property of the collection, not directly on the collection. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the collection instance. synchronized
method on a collection, the expected usage for the xtd::collections::generic::icollection::sync_root looks as follows: Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.
|
inlineoverridevirtualnoexcept |
Gets a collection containing the values in the xtd::collections::generic::dictionary <key_t, value_t>.
Implements xtd::collections::generic::idictionary< key_t, value_t >.
|
inlineoverridevirtual |
Adds an element with the provided key and value to the xtd::collections::generic::dictionary <key_t, value_t>.
key | The object to use as the key of the element to add. |
value | The object to use as the value of the element to add. |
xtd::argument_exception | An element with the same key already exists in the xtd::collections::generic::dictionary <key_t, value_t>. |
xtd::not_supported_exception | The xtd::collections::generic::dictionary <key_t, value_t> is read-only. |
operator []
to add new elements by setting the value of a key that does not exist in the dictionary; for example, my_collection["my_nonexistent_key"] = my_value
. However, if the specified key already exists in the dictionary, setting the operator []
overwrites the old value. In contrast, the xtd::collections::generic::dictionary::add method does not modify existing elements. Implements xtd::collections::generic::idictionary< key_t, value_t >.
|
inlineoverride |
Adds an item to the xtd::collections::generic::icollection <type_t>.
item | The object to add to the xtd::collections::generic::icollection <type_t>. |
xtd::not_supported_exception | The xtd::collections::generic::icollection <type_t> is read-only. |
|
inline |
Gets the element with the specified key.
key | The key of the element to get. |
xtd::collections::generic::key_not_found_exception | The property is retrieved and key is not found. |
xtd::not_supported_exception | The property is set and the xtd::collections::generic::dictionary <key_t, value_t> is read-only. |
|
inline |
Gets the element with the specified key.
key | The key of the element to get. |
xtd::collections::generic::key_not_found_exception | The property is retrieved and key is not found. |
xtd::not_supported_exception | The property is set and the xtd::collections::generic::dictionary <key_t, value_t> is read-only. |
|
inline |
Returns an iterator to the beginning of the specified bucket.
n | The index of the bucket to access. |
n
.
|
inline |
Returns an iterator to the beginning of the specified bucket.
n | The index of the bucket to access. |
n
.
|
inline |
Returns the index of the bucket for key key. Elements (if any) with keys equivalent to key are always found in this bucket.
key | The value of the key to examine. |
|
inlinenoexcept |
Returns the number of elements in the bucket with index n
.
n | The index of the bucket to examine. |
n
.
|
inline |
Returns an iterator to the beginning of the specified bucket.
n | The index of the bucket to access. |
n
.
|
inline |
Returns an iterator to the end of the specified bucket.
n | The index of the bucket to access. |
n
. This element acts as a placeholder, attempting to access it results in undefined behavior.
|
inlineoverridevirtualnoexcept |
Removes all keys and values from the xtd::collections::generic::dictionary <key_t, value_t>.
Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.
|
inlinenoexcept |
Checks if the container contains element with specific key.
key
equivalent to key in the container.
|
inline |
Checks if the container contains element with specific key.
x
. This overload participates in overload resolution only if hasher_t::is_transparent
and equator_t::is_transparent
are valid and each denotes a type. This assumes that such hasher_t
is callable with both contains_key_t
and key_t
type, and that the equator_t
is transparent, which, together, allows calling this function without constructing an instance of key_t
.
|
inlineoverridenoexcept |
Determines whether an element is in the xtd::collections::generic::dictionary <key_t, value_t>.
item | The object to be added to the end of the xtd::collections::generic::dictionary <key_t, value_t>. |
true
if the xtd::collections::generic::dictionary <key_t, value_t> contains an element with the specified item
; otherwise, false
.
|
inlineoverridevirtualnoexcept |
Determines whether the xtd::collections::generic::dictionary <key_t, value_t> contains the specified key.
The | key to locate in the xtd::collections::generic::dictionary <key_t, value_t>. |
true
if the xtd::collections::generic::dictionary <key_t, value_t> contains an element with the specified key
; otherwise, false
. Implements xtd::collections::generic::idictionary< key_t, value_t >.
|
inlineoverride |
Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.
array | The one-dimensional xtd::array that is the destination of the elements copied from xtd::collections::generic::icollection <type_t>. The xtd::array must have zero-based indexing. |
array_index | The zero-based index in array at which copying begins. |
xtd::argument_exception | The number of elements in the source xtd::collections::generic::icollection <type_t> is greater than the available space from `array_index` to the end of the destination `array`. |
|
inline |
Constructs element in-place.
args | The arguments to forward to the constructor of the element. |
true
if and only if the insertion took place. std::pair<const key_t, value_t>)
is called with exactly the same arguments as supplied to emplace, forwarded via std::forward<args_t>(args)....
The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately (see xtd::collections::generic::dictionary::try_emplace if this behavior is undesirable).
|
inline |
constructs elements in-place using a hint
hint | The iterator, used as a suggestion as to where to insert the new element. |
args | The arguments to forward to the constructor of the element. |
hint
as a suggestion where the element should go. std::pair<const key_t, value_t>
) is called with exactly the same arguments as supplied to the function, forwarded with std::forward<args_t>(args)...
.
|
inline |
Returns an iterator to the end of the specified bucket.
n | The index of the bucket to access. |
n
. This element acts as a placeholder, attempting to access it results in undefined behavior.
|
inline |
Returns an iterator to the end of the specified bucket.
n | The index of the bucket to access. |
n
. This element acts as a placeholder, attempting to access it results in undefined behavior.
|
inlinenoexcept |
Ensures that the dictionary can hold up to a specified number of entries without any further expansion of its backing storage.
capacity | The number of entries. |
|
inline |
Returns range of elements matching a specific key.
key | The key value to compare the elements to. |
key
in the container. The range is defined by two iterators, the first pointing to the first element of the wanted range and the second pointing past the last element of the range.
|
inline |
Returns range of elements matching a specific key.
key | The key value to compare the elements to. |
key
in the container. The range is defined by two iterators, the first pointing to the first element of the wanted range and the second pointing past the last element of the range.
|
inline |
Returns range of elements matching a specific key.
x | A value of any type that can be transparently compared with a key. |
x
. This overload participates in overload resolution only if hasher_t::is_transparent
and equator_t::is_transparent
are valid and each denotes a type. This assumes that such Hash is callable with both equal_range_key_t
and key_t
type, and that the equator_t
is transparent, which, together, allows calling this function without constructing an instance of equal_range_key_t
.
|
inline |
Returns range of elements matching a specific key.
x | A value of any type that can be transparently compared with a key. |
x
. This overload participates in overload resolution only if hasher_t::is_transparent
and equator_t::is_transparent
are valid and each denotes a type. This assumes that such Hash is callable with both equal_range_key_t
and key_t
type, and that the equator_t
is transparent, which, together, allows calling this function without constructing an instance of key_t
.
|
inline |
Erases elements.
pos | The iterator to the element to remove. |
pos
. pos
must be valid and dereferenceable. Thus the xtd::collections::generic::dictionary::end iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos
.
|
inline |
Erases elements.
first | The first iterator of the range of elements to remove. |
last | The last iterator of the range of elements to remove. |
first
, last
), which must be a valid range in *this
. pos
must be valid and dereferenceable. Thus the xtd::collections::generic::dictionary::end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos
.
|
inline |
Erases elements.
key | The key value of the elements to remove. |
key
. pos
must be valid and dereferenceable. Thus the xtd::collections::generic::dictionary::end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos
.
|
inlinenoexcept |
Extracts nodes from the container.
position | A valid iterator into this container. |
|
inline |
Extracts nodes from the container.
k | A key to identify the node to be extracted. |
|
inline |
Finds element with specific key.
key | The key value of the element to search for. |
key
.
|
inline |
Finds element with specific key.
key | The key value of the element to search for. |
key
.
|
inline |
Finds element with specific key.
x | A value of any type that can be transparently compared with a key. |
x
. This overload participates in overload resolution only if hasher_t::is_transparent
and equator_t::is_transparent
are valid and each denotes a type. This assumes that such hasher_t
is callable with both find_key_t
and key_t
type, and that the equator_t
is transparent, which, together, allows calling this function without constructing an instance of key_t
.
|
inline |
Finds element with specific key.
x | A value of any type that can be transparently compared with a key. |
x
. This overload participates in overload resolution only if hasher_t::is_transparent
and equator_t::is_transparent
are valid and each denotes a type. This assumes that such hasher_t
is callable with both find_key_t
and key_t
type, and that the equator_t
is transparent, which, together, allows calling this function without constructing an instance of key_t
.
|
inlinenoexcept |
Returns the allocator associated with the container.
|
inlineoverridevirtualnoexcept |
Returns an enumerator that iterates through the xtd::collections::generic::dictionary <key_t, value_t>.
Implements xtd::collections::generic::ienumerable< type_t >.
|
inline |
Returns function used to hash the keys.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
value | The element value to insert. |
true
if and only if the insertion took place. value
.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
value | The element value to insert. |
true
if and only if the insertion took place. value
.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
value | The element value to insert. |
true
if and only if the insertion took place. value
. emplace(std::forward<P>(value))
and only participates in overload resolution if std::is_constructible<value_type, P&&>::value == true
.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
hint | The iterator, used as a suggestion as to where to insert the content. |
value | The element value to insert. |
value
, using hint
as a non-binding suggestion to where the search should start.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
hint | The iterator, used as a suggestion as to where to insert the content. |
value | The element value to insert. |
value
, using hint
as a non-binding suggestion to where the search should start.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
hint | The iterator, used as a suggestion as to where to insert the content. |
value | The element value to insert. |
value
, using hint
as a non-binding suggestion to where the search should start. emplace_hint(hint, std::forward<P>(value))
and only participates in overload resolution if std::is_constructible<value_type, P&&>::value == true
.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
first | The first iterator of the range of elements to insert. |
last | The last iterator of the range of elements to insert. |
first
, last
). If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844). first
, last
) is not a valid range, or first
and/or last
are iterators into *this
, the behavior is undefined.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
ilist | The initializer list to insert the values from. |
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
ilist | The initializer list to insert the values from. |
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
nh | A compatible node handle. |
nh
is empty, inserted is false
, position is xtd::collections::generic::dictionary::end, and node is empty.true
, position points to the inserted element, and node is empty.false
, node has the previous value of nh
, and position points to an element with a key equivalent to nh.key()
. nh
is an empty node handle, does nothing. Otherwise, inserts the element owned by nh into the container , if the container doesn't already contain an element with a key equivalent to nh.key()
. The behavior is undefined if nh
is not empty and get_allocator() != nh.get_allocator()
.
|
inline |
Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
hint | The iterator, used as a suggestion as to where to insert the content. |
nh | A compatible node handle. |
nh
was empty, iterator pointing to the inserted element if insertion took place, and iterator pointing to an element with a key equivalent to nh.key()
if it failed. nh
is an empty node handle, does nothing and returns the end iterator. Otherwise, inserts the element owned by nh into the container, if the container doesn't already contain an element with a key equivalent to nh.key()
, and returns the iterator pointing to the element with key equivalent to nh.key()
(regardless of whether the insert succeeded or failed). If the insertion succeeds, nh
is moved from, otherwise it retains ownership of the element. hint
is used as a non-binding suggestion to where the search should start. The behavior is undefined if nh
is not empty and get_allocator() != nh.get_allocator()
.
|
inline |
Inserts an element or assigns to the current element if the key already exists.
k | The key used both to look up and to insert if not found. |
obj | The value to insert or assign. |
true
if and only if the insertion took place. k
already exists in the container, assigns std::forward<type_t>(obj)
to the xtd::collections::generic::dictionary::mapped_type corresponding to the key k
. If the key does not exist, inserts the new value as if by xtd::collections::generic::dictionary::insert, constructing it from value_type(k, std::forward<type_t>(obj))
.
|
inline |
Inserts an element or assigns to the current element if the key already exists.
k | The key used both to look up and to insert if not found. |
obj | The value to insert or assign. |
true
if and only if the insertion took place. k
already exists in the container, assigns std::forward<type_t>(obj)
to the xtd::collections::generic::dictionary::mapped_type corresponding to the key k
. If the key does not exist, inserts the new value as if by xtd::collections::generic::dictionary::insert, constructing it from value_type(k, std::forward<type_t>(obj))
.
|
inline |
Inserts an element or assigns to the current element if the key already exists.
hint | The iterator to the position before which the new element will be inserted. |
k | The key used both to look up and to insert if not found. |
obj | The value to insert or assign. |
k
already exists in the container, assigns std::forward<type_t>(obj)
to the xtd::collections::generic::dictionary::mapped_type corresponding to the key k
. If the key does not exist, inserts the new value as if by xtd::collections::generic::dictionary::insert, constructing it from value_type(k, std::forward<type_t>(obj))
.
|
inline |
Inserts an element or assigns to the current element if the key already exists.
hint | The iterator to the position before which the new element will be inserted. |
k | The key used both to look up and to insert if not found. |
obj | The value to insert or assign. |
k
already exists in the container, assigns std::forward<type_t>(obj)
to the xtd::collections::generic::dictionary::mapped_type corresponding to the key k
. If the key does not exist, inserts the new value as if by xtd::collections::generic::dictionary::insert, constructing it from value_type(k, std::forward<type_t>(obj))
.
|
inline |
Returns the function used to compare keys for equality.
|
inline |
Splices nodes from another container.
source | A compatible container to transfer the nodes from. |
source
and insert it into *this
using the hash function and key equality predicate of *this
. If there is an element in *this
with key equivalent to the key of an element from source
, then that element is not extracted from source
. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this
, not into source
. Iterators referring to the transferred elements and all iterators referring to *this
are invalidated. Iterators to elements remaining in source
remain valid. get_allocator() != source.get_allocator()
.
|
inline |
Splices nodes from another container.
source | A compatible container to transfer the nodes from. |
source
and insert it into *this
using the hash function and key equality predicate of *this
. If there is an element in *this
with key equivalent to the key of an element from source
, then that element is not extracted from source
. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this
, not into source
. Iterators referring to the transferred elements and all iterators referring to *this
are invalidated. Iterators to elements remaining in source
remain valid. get_allocator() != source.get_allocator()
.
|
inline |
Splices nodes from another container.
source | A compatible container to transfer the nodes from. |
source
and insert it into *this
using the hash function and key equality predicate of *this
. If there is an element in *this
with key equivalent to the key of an element from source
, then that element is not extracted from source
. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this
, not into source
. Iterators referring to the transferred elements and all iterators referring to *this
are invalidated. Iterators to elements remaining in source
remain valid. get_allocator() != source.get_allocator()
.
|
inline |
Splices nodes from another container.
source | A compatible container to transfer the nodes from. |
source
and insert it into *this
using the hash function and key equality predicate of *this
. If there is an element in *this
with key equivalent to the key of an element from source
, then that element is not extracted from source
. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this
, not into source
. Iterators referring to the transferred elements and all iterators referring to *this
are invalidated. Iterators to elements remaining in source
remain valid. get_allocator() != source.get_allocator()
.
|
inline |
Splices nodes from another container.
source | A compatible container to transfer the nodes from. |
source
and insert it into *this
using the hash function and key equality predicate of *this
. If there is an element in *this
with key equivalent to the key of an element from source
, then that element is not extracted from source
. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this
, not into source
. Iterators referring to the transferred elements and all iterators referring to *this
are invalidated. Iterators to elements remaining in source
remain valid. get_allocator() != source.get_allocator()
.
|
inline |
Splices nodes from another container.
source | A compatible container to transfer the nodes from. |
source
and insert it into *this
using the hash function and key equality predicate of *this
. If there is an element in *this
with key equivalent to the key of an element from source
, then that element is not extracted from source
. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this
, not into source
. Iterators referring to the transferred elements and all iterators referring to *this
are invalidated. Iterators to elements remaining in source
remain valid. get_allocator() != source.get_allocator()
.
|
inline |
Reserves at least the specified number of buckets and regenerates the hash table.
count | The lower bound for the new number of buckets. |
count
and satisfies n >= size() / max_load_factor()
, then rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed. rehash(0)
may be used to force an unconditional rehash, such as after suspension of automatic rehashing by temporarily increasing max_load_factor()
.
|
inlineoverridevirtualnoexcept |
Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t, value_t>.
key | The key of the element to remove. |
true
if the element is successfully found and removed; otherwise, false
. This method returns false
if key is not found in the xtd::collections::generic::dictionary <key_t, value_t>. Implements xtd::collections::generic::idictionary< key_t, value_t >.
|
inlineoverridenoexcept |
Removes the first occurrence of a specific object from the xtd::collections::generic::dictionary <key_t, value_t>.
item | The object to remove from the xtd::collections::generic::dictionary <key_t, value_t>. |
true
if item is successfully removed; otherwise, false
. This method also returns false
if item value was not found in the xtd::collections::generic::dictionary <key_t, value_t>.
|
inlinenoexcept |
Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t, value_t>, and copies the element to the value
parameter.
key | The key of the element to remove. |
value | The removed element. |
|
inline |
Reserves space for at least the specified number of elements and regenerates the hash table.
count | The new capacity of the container. |
count
elements without exceeding maximum load factor and rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed. Effectively calls rehash(std::ceil(count / max_load_factor()))
.
|
inlinenoexcept |
Swaps the contents.
The | container to exchange the contents with. |
hasher_t
and equator_t
objects must be Swappable, and they are exchanged using unqualified calls to non-member swap.
|
inlineoverridevirtualnoexcept |
Gets a string that represents the current object.
Reimplemented from xtd::object.
|
inline |
Sets the capacity of this dictionary to hold up a specified number of entries without any further expansion of its backing storage.
capacity | The new capacity. |
xtd::argument_out_of_range_exception | `capacity` is less than xtd::collections::generic::dictionary::count. |
|
inline |
Sets the capacity of this dictionary to what it would be if it had been originally initialized with all its entries.
|
inlinenoexcept |
Attempts to add the specified key and value to the dictionary.
key | The key of the element to add. |
value | The value of the element to add. |
true
if the key/value pair was added to the dictionary successfully; otherwise, false
. false
.
|
inline |
Inserts in-place if the key does not exist, does nothing if the key exists.
k | The key used both to look up and to insert if not found. |
args | The arguments to forward to the constructor of the element. |
true
if and only if the insertion took place.
|
inline |
Inserts in-place if the key does not exist, does nothing if the key exists.
k | The key used both to look up and to insert if not found. |
args | The arguments to forward to the constructor of the element. |
true
if and only if the insertion took place.
|
inline |
Inserts in-place if the key does not exist, does nothing if the key exists.
hint | The iterator to the position before which the new element will be inserted. |
k | The key used both to look up and to insert if not found. |
args | The arguments to forward to the constructor of the element. |
|
inline |
Inserts in-place if the key does not exist, does nothing if the key exists.
hint | The iterator to the position before which the new element will be inserted. |
k | The key used both to look up and to insert if not found. |
args | The arguments to forward to the constructor of the element. |
|
inlineoverridevirtual |
Gets the value associated with the specified key.
key | The key of the value to get. |
value | When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. |
true
if the xtd::collections::generic::dictionary <key_t, value_t> contains an element with the specified key; otherwise, false
. Implements xtd::collections::generic::idictionary< key_t, value_t >.
|
inlinenoexcept |
Move assignment operator. Replaces the contents with a copy of the contents of other
.
other | Another container to use as data source. |
|
inlinenoexcept |
Move assignment operator. Replaces the contents with a copy of the contents of other
.
other | Another container to use as data source. |
|
defaultnoexcept |
Copy assignment operator. Replaces the contents with a copy of the contents of other
.
other | Another container to use as data source. |
|
inlinenoexcept |
Copy assignment operator. Replaces the contents with a copy of the contents of other
.
other | Another container to use as data source. |
|
inline |
Copy assignment operator. Replaces the contents with a copy of the contents of other
.
ilist | The initializer list to use as data source. |
|
inline |
Copy assignment operator. Replaces the contents with a copy of the contents of other
.
ilist | The initializer list to use as data source. |
|
inlineoverridevirtual |
Gets the element with the specified key.
key | The key of the element to get. |
xtd::collections::generic::key_not_found_exception | The property is retrieved and key is not found. |
xtd::not_supported_exception | The property is set and the xtd::collections::generic::dictionary <key_t, value_t> is read-only. |
my_collection[key]
. operator []
to add new elements by setting the value of a key that does not exist in the dictionary; for example, my_collection["my_nonexistent_key"] = my_value
. However, if the specified key already exists in the dictionary, setting the operator []
overwrites the old value. In contrast, the xtd::collections::generic::dictionary::add method does not modify existing elements. Implements xtd::collections::generic::idictionary< key_t, value_t >.
|
inlineoverridevirtual |
Sets the element with the specified key.
key | The key of the element to set. |
xtd::not_supported_exception | The property is set and the xtd::collections::generic::dictionary <key_t, value_t> is read-only. |
my_collection[key]
. operator []
to add new elements by setting the value of a key that does not exist in the dictionary; for example, my_collection["my_nonexistent_key"] = my_value
. However, if the specified key already exists in the dictionary, setting the operator []
overwrites the old value. In contrast, the xtd::collections::generic::dictionary::add method does not modify existing elements. Implements xtd::collections::generic::idictionary< key_t, value_t >.
|
inlinenoexcept |
Returns a reference to the underlying base type.
|
inlinenoexcept |
Returns a reference to the underlying base type.