Represents a generic collection of key/value pairs.
auto
key type and the value type. For example: Public Aliases | |
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. | |
Public Properties | |
virtual key_collection | keys () const noexcept=0 |
Gets an xtd::collections::generic::icollection <type_t> containing the keys of the xtd::collections::generic::idictionary <key_t, value_t>. | |
virtual value_collection | values () const noexcept=0 |
Gets an xtd::collections::generic::icollection <type_t> containing the values of the xtd::collections::generic::idictionary <key_t, value_t>. | |
Public Methods | |
virtual void | add (const key_t &key, const value_t value)=0 |
Adds an element with the provided key and value to the xtd::collections::generic::idictionary <key_t, value_t>. | |
virtual bool | contains_key (const key_t &key) const noexcept=0 |
Determines whether the xtd::collections::generic::idictionary <key_t, value_t> contains an element with the specified key. | |
virtual bool | remove (const key_t &key) noexcept=0 |
Removes the element with the specified key from the xtd::collections::generic::idictionary <key_t, value_t>. | |
virtual bool | try_get_value (const key_t &key, value_t &value) const =0 |
Gets the value associated with the specified key. | |
Public Operators | |
virtual value_t & | operator[] (const key_t &key)=0 |
Sets the element with the specified key. /. | |
using xtd::collections::generic::idictionary< key_t, value_t >::key_type |
Represents the dictionary key type.
using xtd::collections::generic::idictionary< key_t, value_t >::mapped_type |
Represents the dictionary mapped type.
using xtd::collections::generic::idictionary< key_t, value_t >::value_type |
Represents the xtd::collections::generic::idictionary value type.
using xtd::collections::generic::idictionary< key_t, value_t >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type.
using xtd::collections::generic::idictionary< key_t, value_t >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type.
using xtd::collections::generic::idictionary< key_t, value_t >::key_collection |
Represents the idictionary key collection type.
using xtd::collections::generic::idictionary< key_t, value_t >::value_collection |
Represents the idictionary value collection type.
|
pure virtualnoexcept |
Gets an xtd::collections::generic::icollection <type_t> containing the keys of the xtd::collections::generic::idictionary <key_t, value_t>.
Implemented in xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::dictionary< xtd::string, xtd::string >, and xtd::collections::generic::dictionary< xtd::string, xtd::string >.
|
pure virtualnoexcept |
Gets an xtd::collections::generic::icollection <type_t> containing the values of the xtd::collections::generic::idictionary <key_t, value_t>.
Implemented in xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::dictionary< xtd::string, xtd::string >, and xtd::collections::generic::dictionary< xtd::string, xtd::string >.
|
pure virtual |
Adds an element with the provided key and value to the xtd::collections::generic::idictionary <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::idictionary <key_t, value_t>. |
xtd::not_supported_exception | The xtd::collections::generic::idictionary <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::idictionary::add method does not modify existing elements. Implemented in xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, and xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >.
|
pure virtualnoexcept |
Determines whether the xtd::collections::generic::idictionary <key_t, value_t> contains an element with the specified key.
key | The key to locate in the xtd::collections::generic::idictionary <key_t, value_t>. |
true
if the xtd::collections::generic::idictionary <key_t, value_t> contains an element with the key; otherwise, false
. Implemented in xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, and xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >.
|
pure virtualnoexcept |
Removes the element with the specified key from the xtd::collections::generic::idictionary <key_t, value_t>.
key | The key of the element to remove. |
true
if the element is successfully removed; otherwise, false
. This method also returns false
if key was not found in the original xtd::collections::generic::idictionary <key_t, value_t>. Implemented in xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, and xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >.
|
pure virtual |
Gets the value associated with the specified key.
key | The key whose value to get. |
value | When this method returns, 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 object that implements xtd::collections::generic::idictionary <key_t, value_t> contains an element with the specified key; otherwise, false
. value_t
; for example, zero (0) for integer types, false
for Boolean types, and null for reference types Implemented in xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, and xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >.
|
pure virtual |
Sets the element with the specified key. /.
@brief Gets the element with the specified key. @param key The key of the element to get. @return The element with the specified key. @exception xtd::collections::generic::key_not_found_exception The property is retrieved and key is not found. @exception xtd::not_supported_exception The property is set and the xtd::collections::generic::idictionary <key_t, value_t> is read-only. @remarks This property provides the ability to access a specific element in the collection by using the following syntax: `my_collection[key]`. @remarks You can also use the `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 `o`perator []` overwrites the old value. In contrast, the xtd::collections::generic::idictionary::add method does not modify existing elements.
/
key | The key of the element to set. / |
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::idictionary <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::idictionary::add method does not modify existing elements. Implemented in xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, and xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >.