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 |
Represents the dictionary key type. | |
using | mapped_type |
Represents the dictionary mapped type. | |
using | value_type |
Represents the dictionary value type. | |
using | size_type |
Represents the dictionary size type. | |
using | base_value_type |
Represents the dictionary base value type. | |
using | base_type |
Represents the dictionary base type. | |
using | key_collection |
Represents the idictionary key collection type. | |
using | 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_t capacity) | |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the specified initial capacit. | |
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 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 input_iterator_t> | |
dictionary (input_iterator_t first, input_iterator_t last) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. | |
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 (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 (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::initializer_list< base_value_type > init) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. | |
template<class init_key_t, class init_value_t> | |
dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init) | |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. | |
Public Properties | |
size_type | capacity () const noexcept |
Gets the total numbers of elements the internal data structure can hold without resizing. | |
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>. | |
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>. | |
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>. | |
void | clear () noexcept override |
Removes all keys and values from the xtd::collections::generic::dictionary <key_t, value_t>. | |
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 |
Determines whether the xtd::collections::generic::dictionary <key_t, value_t> contains the specified value. | |
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. | |
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. | |
enumerator< value_type > | get_enumerator () const noexcept override |
Returns an enumerator that iterates through the xtd::collections::generic::dictionary <key_t, value_t>. | |
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. | |
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. | |
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 |
Represents the dictionary key type. | |
using | mapped_type |
Represents the dictionary mapped type. | |
using | value_type |
Represents the xtd::collections::generic::idictionary value type. | |
using | iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
using | key_collection |
Represents the idictionary key collection type. | |
using | value_collection |
Represents the idictionary value collection 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::unique_ptr_object< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
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. | |
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_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 |
Represents the dictionary mapped type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::value_type |
Represents the dictionary value type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::size_type |
Represents the dictionary size type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::base_value_type |
Represents the dictionary base value type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::base_type |
Represents the dictionary base type.
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::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 |
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.
|
inline |
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the specified initial capacit.
capacity | The initial number of elements that the xtd::collections::generic::dictionary <key_t, value_t> can contain. |
dictionary
must also be unique according to the specified comparer.
|
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.
|
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. |
|
inlineexplicit |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources.
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. |
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
|
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. |
other
using move semantics. If alloc
is not provided, allocator is obtained by move-construction from the allocator belonging to other.
|
inline |
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources.
init | Initializer list to initialize the elements of the container with. |
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.
init | Initializer list to initialize the elements of the container with. |
xtd::argument_exception | `dictionary` contains one or more duplicate keys. |
|
inlinenoexcept |
Gets the total numbers of elements the internal data structure can hold without resizing.
|
inlinenoexcept |
Gets the td::collections::generic::iequality_comparer <type_t> that is used to determine equality of keys for the dictionary.
|
inlineoverridenoexcept |
Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <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 >.
|
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. |
|
inlineoverridenoexcept |
Removes all keys and values from the xtd::collections::generic::dictionary <key_t, value_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 >.
|
inlinenoexcept |
Determines whether the xtd::collections::generic::dictionary <key_t, value_t> contains the specified value.
The | value 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
.
|
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`. |
|
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. |
|
inlineoverridenoexcept |
Returns an enumerator that iterates through the xtd::collections::generic::dictionary <key_t, value_t>.
|
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. |
|
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
.
|
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. |
|
inlineoverride |
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.
|
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.