xtd 0.2.0
Loading...
Searching...
No Matches
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t > Class Template Reference
Inheritance diagram for xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >:
xtd::object xtd::collections::generic::idictionary< key_t, value_t > xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > > xtd::interface xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t > xtd::collections::generic::extensions::enumerable< enumerable_t, source_t >

Definition

template<typename key_t, typename value_t, typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
class xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >

Represents a collection of keys and values.

Definition
template<typename key_t, typename value_t, typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
class dictionary : public xtd::object, public xtd::collections::generic::idictionary<key_t, value_t>;
Represents a collection of keys and values.
Definition dictionary.hpp:57
Represents a generic collection of key/value pairs.
Definition idictionary.hpp:35
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:42
std::allocator< type_t > allocator
Represent an allocator alias.
Definition allocator.hpp:35
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:37
Header
#include <xtd/collections/dictionary
Namespace
xtd::collections::generic
Library
xtd.core
Remarks
The xtd::collections::generic::dictionary class is same as std::unordered_map.
Examples
The following shows how to use xtd::collections::generic::dictionary.
Remarks
The xtd::collections::generic::dictionary <key_t, value_t> generic class provides a mapping from a set of keys to a set of values. Each addition to the dictionary consists of a value and its associated key. Retrieving a value by using its key is very fast, close to O(1), because the xtd::collections::generic::dictionary <key_t, value_t> class is implemented as a hash table.
Note
The speed of retrieval depends on the quality of the hashing algorithm of the type specified for key_t.
Remarks
As long as an object is used as a key in the xtd::collections::generic::dictionary <key_t, value_t>, it must not change in any way that affects its hash value. Every key in a xtd::collections::generic::dictionary <key_t, value_t> must be unique according to the dictionary's equality comparer.
xtd::collections::generic::dictionary <key_t, value_t> requires an equality implementation to determine whether keys are equal. 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; if you do not specify an implementation, the default generic equality comparer xtd::collections::generic::equality_comparer<type_t>::default_equality_comparer is used. If type key_t implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
Note
For example, you can use the case-insensitive string comparers provided by the xtd::string_comparer class to create dictionaries with case-insensitive string keys.
Remarks
The capacity of a xtd::collections::generic::dictionary <key_t, value_t> is the number of elements the xtd::collections::generic::dictionary <key_t, value_t> can hold. As elements are added to a xtd::collections::generic::dictionary <key_t, value_t>, the capacity is automatically increased as required by reallocating the internal array.
For purposes of enumeration, each item in the dictionary is treated as a xtd::collections::generic::key_value_pair <key_t, value_t> structure representing a value and its key. The order in which the items are returned is undefined.
The for each statement returns an object of the type of the elements in the collection. Since the xtd::collections::generic::dictionary <key_t, value_t> is a collection of keys and values, the element type is not the type of the key or the type of the value. Instead, the element type is a xtd::collections::generic::key_value_pair <key_t, value_t> of the key type and the value type. For example:
for (const key_value_pair<string, string>& kvp : my_dictionary)
console::write_line("key = {}, value = {}", kvp.key(), kvp.value());
Represents the standard input, output, and error streams for console applications.
Definition console.hpp:36
Defines a key/value pair that can be set or retrieved.
Definition key_value_pair.hpp:36
Or with auto key type and the value type. For example:
for (const auto& [key, value] : my_dictionary)
console::write_line("key = {}, value = {}", key, value);

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 hasher = hasher_t
 Represents the dictionary hasher type.
 
using equator = equator_t
 Represents the dictionary equator type.
 
using key_equal = equator_t
 Represents the dictionary equator 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 (size_type bucket_count, const hasher &hash=hasher {}, const equator &equal=equator {}, 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 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 (size_type bucket_count, const hasher &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.
 
 dictionary (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<typename input_iterator_t >
 dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count=0, const hasher &hash=hasher {}, const equator &equal=equator {}, 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.
 
template<typename input_iterator_t >
 dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count, 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<typename input_iterator_t >
 dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count, const hasher &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.
 
 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 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 (const 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 (const 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 (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 &hash=hasher {}, const equator &equal=equator {}, 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 &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<typename init_key_t , typename init_value_t >
 dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init, size_type bucket_count=0, const hasher &hash=hasher {}, const equator &equal=equator {}, 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<typename init_key_t , typename 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<typename init_key_t , typename init_value_t >
 dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init, size_type bucket_count, const hasher &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.
 
size_type count () const noexcept
 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.
 
virtual const base_typeitems () const noexcept
 Returns the underlying base type items.
 
virtual base_typeitems () 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>.
 
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>.
 
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.
 
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.
 
void clear () noexcept
 Erases all elements from the container. After this call, xtd::collections::generic::dictionary::size returns zero.
 
allocator_type get_allocator () const noexcept
 Returns the allocator associated with the container.
 
enumerator< value_typeget_enumerator () const noexcept override
 Returns an enumerator that iterates through the xtd::collections::generic::dictionary <key_t, value_t>.
 

Public Operators

dictionaryoperator= (dictionary &&other) noexcept
 Move assignment operator. Replaces the contents with a copy of the contents of other.
 
dictionaryoperator= (std::unordered_map< key_t, value_t > &&other) noexcept
 Move assignment operator. Replaces the contents with a copy of the contents of other.
 
dictionaryoperator= (const dictionary &other) noexcept=default
 Copy assignment operator. Replaces the contents with a copy of the contents of other.
 
dictionaryoperator= (const std::unordered_map< key_t, value_t > &other) noexcept
 Copy assignment operator. Replaces the contents with a copy of the contents of other.
 
dictionaryoperator= (std::initializer_list< base_value_type > ilist)
 Copy assignment operator. Replaces the contents with a copy of the contents of other.
 
template<typename init_key_t , typename init_value_t >
dictionaryoperator= (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

- Public Types inherited from xtd::collections::generic::idictionary< key_t, value_t >
using key_type = key_t
 Represents the dictionary key type.
 
using mapped_type = value_t
 Represents the dictionary mapped type.
 
using value_type = xtd::collections::generic::key_value_pair< key_type, mapped_type >
 Represents the dictionary 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.
 
- Public Types inherited from xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > >
using iterator = typename xtd::collections::generic::extensions::enumerable_iterators< xtd::collections::generic::key_value_pair< key_t, value_t >, 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::extensions::enumerable_iterators< xtd::collections::generic::key_value_pair< key_t, value_t >, 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.
 
- Public Types inherited from xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t >
using const_iterator = const iterator
 Represents the const iterator of enumarable value type.
 
- Public Types inherited from xtd::collections::generic::extensions::enumerable< enumerable_t, source_t >
template<typename type_t >
using ienumerable = typename xtd::linq::enumerable::ienumerable< type_t >
 Represents the ienumerable value type.
 
template<typename type_t >
using list = typename xtd::linq::enumerable::list< type_t >
 Represents the list value type.
 
- Public Member Functions inherited from xtd::object
 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 size_t 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<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
virtual xtd::string to_string () const noexcept
 Returns a xtd::string that represents the current object.
 
- Public Member Functions inherited from xtd::collections::generic::idictionary< key_t, value_t >
- Public Member Functions inherited from xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > >
- Public Member Functions inherited from xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t >
- Public Member Functions inherited from xtd::collections::generic::extensions::enumerable< enumerable_t, source_t >
source_t aggregate (const std::function< source_t(const source_t &, const source_t &)> &func) const
 Applies an accumulator function over a sequence.
 
source_t aggregate (const source_t &seed, const std::function< source_t(const source_t &, const source_t &)> &func) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
 
template<typename accumulate_t >
accumulate_t aggregate (const accumulate_t &seed, const std::function< accumulate_t(const source_t &, const accumulate_t &)> &func) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
 
source_t aggregate (const source_t &seed, const std::function< source_t(const source_t &, const source_t &)> &func, const std::function< source_t(const source_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.
 
template<typename result_t , typename accumulate_t >
result_t aggregate (const accumulate_t &seed, const std::function< accumulate_t(const source_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 source_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 source_t &)> &predicate) const
 Determines whether any element of a sequence satisfies a condition.
 
const ienumerable< source_t > & append (const source_t &element) const noexcept
 Appends a value to the end of the sequence.
 
const ienumerable< source_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.
 
template<typename result_t >
const ienumerable< result_t > & cast () const noexcept
 Casts the elements of an xtd::collection::generic::ienumerable to the specified type.
 
const ienumerable< xtd::array< source_t > > & chunk (size_t size) const
 Splits the elements of a sequence into chunks of size at most size.
 
const ienumerable< source_t > & concat (const ienumerable< source_t > &second) const noexcept
 Concatenates two sequences.
 
bool contains (const source_t &value) const noexcept
 Determines whether a sequence contains a specified element by using the default equality comparer.
 
bool contains (const source_t &value, const xtd::collections::generic::iequality_comparer< source_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 source_t &)> &predicate) const noexcept
 Returns a number that represents how many elements in the specified sequence satisfy a condition.
 
template<typename key_t >
const ienumerable< key_value_pair< key_t, xtd::size > > & count_by (const std::function< key_t(const source_t &)> &key_selector) const noexcept
 Returns the count of elements in the current sequence grouped by key.
 
template<typename key_t >
const ienumerable< key_value_pair< key_t, xtd::size > > & count_by (const std::function< key_t(const source_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< source_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< source_t > & default_if_empty (const source_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.
 
source_t first_or_default (const std::function< bool(const source_t &)> &predicate, const source_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.
 
source_t first_or_default (const std::function< bool(const source_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.
 
source_t first_or_default (const source_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.
 
source_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.
 
template<typename result_t >
const ienumerable< result_t > & select (const std::function< result_t(const source_t &)> &selector) const
 Projects each element of a sequence into a new form.
 
const ienumerable< source_t > & select (const std::function< source_t(const source_t &)> &selector) const
 Projects each element of a sequence into a new form.
 
template<typename result_t >
const ienumerable< result_t > & select (const std::function< result_t(const source_t &, size_t index)> &selector) const
 Projects each element of a sequence into a new form by incorporating the element's index.
 
const ienumerable< source_t > & select (const std::function< source_t(const source_t &, size_t index)> &selector) const
 Projects each element of a sequence into a new form by incorporating the element's index.
 
const list< source_t > & to_list () const noexcept
 Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
 
const ienumerable< source_t > & where (const std::function< bool(const source_t &)> &predicate) const
 Filters a sequence of values based on a predicate.
 
const ienumerable< source_t > & where (const std::function< bool(const source_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.
 
- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename 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<typename object_a_t , typename 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.
 

Member Typedef Documentation

◆ key_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ mapped_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ value_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ size_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::size_type = xtd::size

Represents the dictionary size type.

◆ difference_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::difference_type = xtd::ptrdiff

Represents the dictionary difference type.

◆ hasher

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::hasher = hasher_t

Represents the dictionary hasher type.

◆ equator

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::equator = equator_t

Represents the dictionary equator type.

◆ key_equal

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::key_equal = equator_t

Represents the dictionary equator type.

◆ allocator_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::allocator_type = allocator_t

Represents the dictionary allocator type.

◆ base_value_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ base_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ reference

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
using xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::reference = value_type&

Represents the dictionary reference type.

◆ const_reference

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ pointer

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ const_pointer

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ iterator

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ const_iterator

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ local_iterator

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ const_local_iterator

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ node_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ insert_return_type

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ key_collection

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

◆ value_collection

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
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.

Constructor & Destructor Documentation

◆ dictionary() [1/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( )
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.

Remarks
Every key in a xtd::collections::generic::dictionary <key_t, value_t> must be unique according to the default equality comparer.
xtd::collections::generic::dictionary <key_t, value_t> requires an equality implementation to determine whether keys are equal. This constructor uses the default generic equality comparer, equality_comparer::default. If 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.
Note
If you can estimate the size of the collection, using a constructor that specifies the initial capacity eliminates the need to perform a number of resizing operations while adding elements to the xtd::collections::generic::dictionary <key_t, value_t>.
Remarks
Constructs empty container. Sets xtd::collections::generic::dictionary::max_load_factor() to 1.0. For the default constructor, the number of buckets is implementation-defined.
This constructor is an O(1) operation.
Examples
The following code example creates an empty xtd::collections::generic::dictionary <key_t, value_t> of strings with string keys and uses the Add method to add some elements. The example demonstrates that the dictionary::add method throws an xtd::argument_exception when attempting to add a duplicate key.

This code example is part of a larger example provided for the xtd::collections::generic::dictionary <key_t, value_t> class.

// Create a new dictionary of strings, with string keys.
//
auto open_with = dictionary<string, string> {};
// Add some elements to the dictionary. There are no
// duplicate keys, but some of the values are duplicates.
open_with.add("txt", "notepad.exe");
open_with.add("bmp", "paint.exe");
open_with.add("dib", "paint.exe");
open_with.add("rtf", "wordpad.exe");
// The add method throws an exception if the new key is
// already in the dictionary.
try {
open_with.add("txt", "winword.exe");
} catch (const argument_exception&) {
console::write_line("An element with Key = \"txt\" already exists.");
}
The exception that is thrown when one of the arguments provided to a method is not valid.
Definition argument_exception.hpp:24
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,...
Definition dictionary.hpp:435
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...

◆ dictionary() [2/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( size_type  bucket_count,
const hasher hash = hasher {},
const equator equal = equator {},
const allocator_type alloc = allocator_type {} 
)
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.

Parameters
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
hashHash function to use.
equalComparison function to use for all key comparisons of this container.
allocAllocator to use for all memory allocations of this container.
Remarks
Constructs empty container. Sets xtd::collections::generic::dictionary::max_load_factor() to 1.0. For the default constructor, the number of buckets is implementation-defined.

◆ dictionary() [3/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( size_type  bucket_count,
const allocator_type alloc 
)
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.

Parameters
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
allocAllocator to use for all memory allocations of this container.
Remarks
Constructs empty container. Sets xtd::collections::generic::dictionary::max_load_factor() to 1.0. For the default constructor, the number of buckets is implementation-defined.

◆ dictionary() [4/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( size_type  bucket_count,
const hasher hash,
const allocator_type alloc 
)
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.

Parameters
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
hashHash function to use.
allocAllocator to use for all memory allocations of this container.
Remarks
Constructs empty container. Sets xtd::collections::generic::dictionary::max_load_factor() to 1.0. For the default constructor, the number of buckets is implementation-defined.

◆ dictionary() [5/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( const allocator_type alloc)
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.

Parameters
allocAllocator to use for all memory allocations of this container.
Remarks
Constructs empty container. Sets xtd::collections::generic::dictionary::max_load_factor() to 1.0. For the default constructor, the number of buckets is implementation-defined.

◆ dictionary() [6/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
template<typename input_iterator_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( input_iterator_t  first,
input_iterator_t  last,
size_type  bucket_count = 0,
const hasher hash = hasher {},
const equator equal = equator {},
const allocator_type alloc = allocator_type {} 
)
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.

Parameters
firstThe fist iterator of the range [first, last) to copy the elements from.
lastThaae last itezrator of the range [first, last) to copy the elements from.
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
hashHash function to use.
equalComparison function to use for all key comparisons of this container.
allocAllocator to use for all memory allocations of this container.
Remarks
Constructs the container with the contents of the range [first, last). Sets xtd::collections::generic::dictionary::max_load_factor() to 1.0. If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844.

◆ dictionary() [7/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
template<typename input_iterator_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( input_iterator_t  first,
input_iterator_t  last,
size_type  bucket_count,
const allocator_type alloc 
)
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.

Parameters
firstThe fist iterator of the range [first, last) to copy the elements from.
lastThaae last itezrator of the range [first, last) to copy the elements from.
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
allocAllocator to use for all memory allocations of this container.
Remarks
Constructs the container with the contents of the range [first, last). Sets xtd::collections::generic::dictionary::max_load_factor() to 1.0. If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844.

◆ dictionary() [8/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
template<typename input_iterator_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( input_iterator_t  first,
input_iterator_t  last,
size_type  bucket_count,
const hasher hash,
const allocator_type alloc 
)
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.

Parameters
firstThe fist iterator of the range [first, last) to copy the elements from.
lastThaae last itezrator of the range [first, last) to copy the elements from.
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
hashHash function to use.
allocAllocator to use for all memory allocations of this container.
Remarks
Constructs the container with the contents of the range [first, last). Sets xtd::collections::generic::dictionary::max_load_factor() to 1.0. If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844.

◆ dictionary() [9/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( const dictionary< key_t, value_t, hasher_t, equator_t, allocator_t > &  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.

Parameters
otherAnother container to be used as source to initialize the elements of the container with.
Remarks
Copy constructor. Constructs the container with the copy of the contents of other, copies the load factor, the predicate, and the hash function as well. If alloc is not provided, allocator is obtained by calling
std::allocator_traits<allocator_type>::select_on_container_copy_construction(other.get_allocator())
@ other
The operating system is other.

◆ dictionary() [10/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( const dictionary< key_t, value_t, hasher_t, equator_t, allocator_t > &  other,
const allocator_type alloc 
)
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.

Parameters
otherAnother container to be used as source to initialize the elements of the container with.
allocAllocator to use for all memory allocations of this container.
Remarks
Copy constructor. Constructs the container with the copy of the contents of other, copies the load factor, the predicate, and the hash function as well. If alloc is not provided, allocator is obtained by calling
std::allocator_traits<allocator_type>::select_on_container_copy_construction(other.get_allocator())

◆ dictionary() [11/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( const std::unordered_map< key_t, value_t > &  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.

Parameters
otherAnother container to be used as source to initialize the elements of the container with.
Remarks
Copy constructor. Constructs the container with the copy of the contents of other, copies the load factor, the predicate, and the hash function as well. If alloc is not provided, allocator is obtained by calling
std::allocator_traits<allocator_type>::select_on_container_copy_construction(other.get_allocator())

◆ dictionary() [12/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( const std::unordered_map< key_t, value_t > &  other,
const allocator_type alloc 
)
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.

Parameters
otherAnother container to be used as source to initialize the elements of the container with.
allocAllocator to use for all memory allocations of this container.
Remarks
Copy constructor. Constructs the container with the copy of the contents of other, copies the load factor, the predicate, and the hash function as well. If alloc is not provided, allocator is obtained by calling
std::allocator_traits<allocator_type>::select_on_container_copy_construction(other.get_allocator())

◆ dictionary() [13/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( dictionary< key_t, value_t, hasher_t, equator_t, allocator_t > &&  other)
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.

Parameters
otherAnother container to be used as source to initialize the elements of the container with.
Remarks
Move constructor. Constructs the container with the contents of other using move semantics. If alloc is not provided, allocator is obtained by move-construction from the allocator belonging to other.

◆ dictionary() [14/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( dictionary< key_t, value_t, hasher_t, equator_t, allocator_t > &&  other,
const allocator_type alloc 
)
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.

Parameters
otherAnother container to be used as source to initialize the elements of the container with.
allocAllocator to use for all memory allocations of this container.
Remarks
Move constructor. Constructs the container with the contents of other using move semantics. If alloc is not provided, allocator is obtained by move-construction from the allocator belonging to other.

◆ dictionary() [15/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( std::unordered_map< key_t, value_t > &&  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.

Parameters
otherAnother container to be used as source to initialize the elements of the container with.
Remarks
Move constructor. Constructs the container with the contents of other using move semantics. If alloc is not provided, allocator is obtained by move-construction from the allocator belonging to other.

◆ dictionary() [16/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( std::unordered_map< key_t, value_t > &&  other,
const allocator_type alloc 
)
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.

Parameters
otherAnother container to be used as source to initialize the elements of the container with.
allocAllocator to use for all memory allocations of this container.
Remarks
Move constructor. Constructs the container with the contents of other using move semantics. If alloc is not provided, allocator is obtained by move-construction from the allocator belonging to other.

◆ dictionary() [17/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( std::initializer_list< base_value_type init,
size_type  bucket_count = 0,
const hasher hash = hasher {},
const equator equal = equator {},
const allocator_type alloc = allocator_type {} 
)
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.

Parameters
initInitializer list to initialize the elements of the container with.
hashHash function to use.
equalComparison function to use for all key comparisons of this container.
allocAllocator to use for all memory allocations of this container.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())
dictionary() noexcept=default
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that i...

◆ dictionary() [18/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( std::initializer_list< base_value_type init,
size_type  bucket_count,
const allocator_type alloc 
)
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.

Parameters
initInitializer list to initialize the elements of the container with.
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
allocAllocator to use for all memory allocations of this container.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())

◆ dictionary() [19/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( std::initializer_list< base_value_type init,
size_type  bucket_count,
const hasher hash,
const allocator_type alloc 
)
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.

Parameters
initInitializer list to initialize the elements of the container with.
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
hashHash function to use.
allocAllocator to use for all memory allocations of this container.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())

◆ dictionary() [20/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
template<typename init_key_t , typename init_value_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( std::initializer_list< key_value_pair< init_key_t, init_value_t > >  init,
size_type  bucket_count = 0,
const hasher hash = hasher {},
const equator equal = equator {},
const allocator_type alloc = allocator_type {} 
)
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.

Parameters
initInitializer list to initialize the elements of the container with.
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
hashHash function to use.
equalComparison function to use for all key comparisons of this container.
allocAllocator to use for all memory allocations of this container.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())

◆ dictionary() [21/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
template<typename init_key_t , typename init_value_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( std::initializer_list< key_value_pair< init_key_t, init_value_t > >  init,
size_type  bucket_count,
const allocator_type alloc 
)
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.

Parameters
initInitializer list to initialize the elements of the container with.
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
allocAllocator to use for all memory allocations of this container.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())

◆ dictionary() [22/22]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
template<typename init_key_t , typename init_value_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( std::initializer_list< key_value_pair< init_key_t, init_value_t > >  init,
size_type  bucket_count,
const hasher hash,
const allocator_type alloc 
)
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.

Parameters
initInitializer list to initialize the elements of the container with.
bucket_countMinimal number of buckets to use on initialization. If it is not specified, implementation-defined default value is used.
hashHash function to use.
allocAllocator to use for all memory allocations of this container.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())

Member Function Documentation

◆ begin() [1/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
const_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::begin ( ) const
inlineoverridevirtualnoexcept

Returns an iterator to the first element of the enumarable.

Returns
Iterator to the first element.

Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t >.

◆ begin() [2/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::begin ( )
inlineoverridevirtualnoexcept

Returns an iterator to the first element of the enumarable.

Returns
Iterator to the first element.

Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t >.

◆ bucket_count()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
size_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::bucket_count ( ) const
inlinenoexcept

Gets the number of buckets in the container.

Returns
The number of buckets in the container.

◆ capacity()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
size_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::capacity ( ) const
inlinenoexcept

Gets the total numbers of elements the internal data structure can hold without resizing.

Returns
The total numbers of elements the internal data structure can hold without resizing.

◆ cbegin()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
const_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::cbegin ( ) const
inlineoverridevirtualnoexcept

Returns an iterator to the first element of the enumarable.

Returns
Iterator to the first element.

Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t >.

◆ cend()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
const_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::cend ( ) const
inlineoverridevirtualnoexcept

Returns an iterator to the element following the last element of the enumarable.

Returns
Iterator to the element following the last element.

Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t >.

◆ count()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
size_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::count ( ) const
inlinenoexcept

Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>.

Returns
the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>.
Remarks
The capacity of a xtd::collections::generic::dictionary <key_t, value_t> is the number of elements that the xtd::collections::generic::dictionary <key_t, value_t> can store. The xtd::collections::generic::dictionary::count property is the number of elements that are actually in the xtd::collections::generic::dictionary <key_t, value_t>.
The capacity is always greater than or equal to xtd::collections::generic::dictionary::count. If xtd::collections::generic::dictionary::count exceeds the capacity while adding elements, the capacity is increased by automatically reallocating the internal array before copying the old elements and adding the new elements.
Getting the value of this property is an O(1) operation.

◆ empty()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
bool xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::empty ( ) const
inlinenoexcept

Checks if the container has no elements, i.e. whether begin() == end().

Returns
true if the container is empty; otherwise false.

◆ end() [1/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
const_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::end ( ) const
inlineoverridevirtualnoexcept

Returns an iterator to the element following the last element of the enumarable.

Returns
Iterator to the element following the last element.

Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t >.

◆ end() [2/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::end ( )
inlineoverridevirtualnoexcept

Returns an iterator to the element following the last element of the enumarable.

Returns
Iterator to the element following the last element.

Reimplemented from xtd::collections::generic::extensions::enumerable_iterators< type_t, enumerable_t >.

◆ items() [1/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
virtual const base_type & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::items ( ) const
inlinevirtualnoexcept

Returns the underlying base type items.

Returns
The underlying base type items.

◆ items() [2/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
virtual base_type & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::items ( )
inlinevirtualnoexcept

Returns the underlying base type items.

Returns
The underlying base type items.

◆ keys()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
key_collection xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::keys ( ) const
inlineoverridevirtualnoexcept

Gets a collection containing the keys in the xtd::collections::generic::dictionary <key_t, value_t>.

Returns
A xtd::collections::generic::dictionary::key_collection containing the keys in the xtd::collections::generic::dictionary <key_t, value_t>.
Remarks
The order of the keys in the xtd::collections::generic::dictionary::key_collection is unspecified, but it is the same order as the associated values in the xtd::collections::generic::dictionary::value_collection returned by the xtd::collections::generic::dictionary::values property.
Getting the value of this property is an O(1) operation.

Implements xtd::collections::generic::idictionary< key_t, value_t >.

◆ load_factor()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
float xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::load_factor ( ) const
inline

Gets the average number of elements per bucket, that is, xtd::collections::generic::dictionary::size divided by xtd::collections::generic::dictionary::bucket_count.

Returns
Average number of elements per bucket.

◆ max_bucket_count()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
size_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::max_bucket_count ( ) const
inlinenoexcept

Gets the maximum number of buckets the container is able to hold due to system or library implementation limitations.

Returns
Maximum number of buckets.

◆ max_load_factor() [1/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
float xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::max_load_factor ( ) const
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.

Returns
The current maximum load factor.

◆ max_load_factor() [2/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::max_load_factor ( float  value) const
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.

Parameters
valueThe new maximum load factor setting.

◆ max_size()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
size_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::max_size ( ) const
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.

Returns
Maximum number of elements.
Remarks
This value typically reflects the theoretical limit on the size of the container, at most 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.

◆ size()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
size_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::size ( ) const
inlinenoexcept

Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>.

Returns
the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>.
Remarks
The capacity of a xtd::collections::generic::dictionary <key_t, value_t> is the number of elements that the xtd::collections::generic::dictionary <key_t, value_t> can store. The xtd::collections::generic::dictionary::count property is the number of elements that are actually in the xtd::collections::generic::dictionary <key_t, value_t>.
The capacity is always greater than or equal to xtd::collections::generic::dictionary::count. If xtd::collections::generic::dictionary::count exceeds the capacity while adding elements, the capacity is increased by automatically reallocating the internal array before copying the old elements and adding the new elements.
Getting the value of this property is an O(1) operation.

◆ values()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
value_collection xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::values ( ) const
inlineoverridevirtualnoexcept

Gets a collection containing the values in the xtd::collections::generic::dictionary <key_t, value_t>.

Returns
A xtd::collections::generic::dictionary::value_collection containing the values in the xtd::collections::generic::dictionary <key_t, value_t>.
Remarks
The order of the values in the xtd::collections::generic::dictionary::value_collection is unspecified, but it is the same order as the associated keys in the xtd::collections::generic::dictionary::key_collection returned by the xtd::collections::generic::dictionary::keys property.
Getting the value of this property is an O(1) operation.

Implements xtd::collections::generic::idictionary< key_t, value_t >.

◆ add()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::add ( const key_t &  key,
const value_t  value 
)
inlineoverridevirtual

Adds an element with the provided key and value to the xtd::collections::generic::dictionary <key_t, value_t>.

Parameters
keyThe object to use as the key of the element to add.
valueThe object to use as the value of the element to add.
Exceptions
xtd::argument_exceptionAn element with the same key already exists in the xtd::collections::generic::dictionary <key_t, value_t>.
xtd::not_supported_exceptionThe xtd::collections::generic::dictionary <key_t, value_t> is read-only.
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 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 >.

◆ at() [1/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
const value_t & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::at ( const key_t &  key) const
inline

Gets the element with the specified key.

Parameters
keyThe key of the element to get.
Returns
The element with the specified key.
Exceptions
xtd::collections::generic::key_not_found_exceptionThe property is retrieved and key is not found.
xtd::not_supported_exceptionThe property is set and the xtd::collections::generic::dictionary <key_t, value_t> is read-only.

◆ at() [2/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
value_t & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::at ( const key_t &  key)
inline

Gets the element with the specified key.

Parameters
keyThe key of the element to get.
Returns
The element with the specified key.
Exceptions
xtd::collections::generic::key_not_found_exceptionThe property is retrieved and key is not found.
xtd::not_supported_exceptionThe property is set and the xtd::collections::generic::dictionary <key_t, value_t> is read-only.

◆ bucket()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
size_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::bucket ( const key_t &  key) const
inline

Returns the index of the bucket for key key. Elements (if any) with keys equivalent to key are always found in this bucket.

Parameters
keyThe value of the key to examine.
Returns
Bucket index for the requested key.

◆ bucket_size()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
size_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::bucket_size ( size_type  n) const
inlinenoexcept

Returns the number of elements in the bucket with index n.

Parameters
nThe index of the bucket to examine.
Returns
The number of elements in the bucket n.

◆ clear()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::clear ( )
inlinenoexcept

Erases all elements from the container. After this call, xtd::collections::generic::dictionary::size returns zero.

Remarks
Invalidates any references, pointers, and iterators referring to contained elements. May also invalidate past-the-end iterators.

◆ get_allocator()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
allocator_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::get_allocator ( ) const
inlinenoexcept

Returns the allocator associated with the container.

Returns
The associated allocator.

◆ get_enumerator()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
enumerator< value_type > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::get_enumerator ( ) const
inlineoverridevirtualnoexcept

◆ operator=() [1/6]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
dictionary & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator= ( dictionary< key_t, value_t, hasher_t, equator_t, allocator_t > &&  other)
inlinenoexcept

Move assignment operator. Replaces the contents with a copy of the contents of other.

Parameters
otherAnother container to use as data source.
Returns
This current instance.

◆ operator=() [2/6]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
dictionary & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator= ( std::unordered_map< key_t, value_t > &&  other)
inlinenoexcept

Move assignment operator. Replaces the contents with a copy of the contents of other.

Parameters
otherAnother container to use as data source.
Returns
This current instance.

◆ operator=() [3/6]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
dictionary & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator= ( const dictionary< key_t, value_t, hasher_t, equator_t, allocator_t > &  other)
defaultnoexcept

Copy assignment operator. Replaces the contents with a copy of the contents of other.

Parameters
otherAnother container to use as data source.
Returns
This current instance.

◆ operator=() [4/6]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
dictionary & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator= ( const std::unordered_map< key_t, value_t > &  other)
inlinenoexcept

Copy assignment operator. Replaces the contents with a copy of the contents of other.

Parameters
otherAnother container to use as data source.
Returns
This current instance.

◆ operator=() [5/6]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
dictionary & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator= ( std::initializer_list< base_value_type ilist)
inline

Copy assignment operator. Replaces the contents with a copy of the contents of other.

Parameters
ilistThe initializer list to use as data source.
Returns
This current instance.

◆ operator=() [6/6]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
template<typename init_key_t , typename init_value_t >
dictionary & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator= ( std::initializer_list< key_value_pair< init_key_t, init_value_t > >  ilist)
inline

Copy assignment operator. Replaces the contents with a copy of the contents of other.

Parameters
ilistThe initializer list to use as data source.
Returns
This current instance.

◆ operator[]() [1/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
const value_t & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator[] ( const key_t &  key) const
inlineoverridevirtual

Gets the element with the specified key.

Parameters
keyThe key of the element to get.
Returns
The element with the specified key.
Exceptions
xtd::collections::generic::key_not_found_exceptionThe property is retrieved and key is not found.
xtd::not_supported_exceptionThe property is set and the xtd::collections::generic::dictionary <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].
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 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 >.

◆ operator[]() [2/2]

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
value_t & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator[] ( const key_t &  key)
inlineoverridevirtual

Sets the element with the specified key.

Parameters
keyThe key of the element to set.
Returns
The element with the specified key.
Exceptions
xtd::not_supported_exceptionThe property is set and the xtd::collections::generic::dictionary <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].
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 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 >.

◆ operator const base_type &()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator const base_type & ( ) const
inlinenoexcept

Returns a reference to the underlying base type.

Returns
Reference to the underlying base type.

◆ operator base_type &()

template<typename key_t , typename value_t , typename hasher_t = xtd::collections::generic::helpers::hasher<key_t>, typename equator_t = xtd::collections::generic::helpers::equator<key_t>, typename allocator_t = xtd::collections::generic::helpers::allocator<std::pair<const key_t, value_t>>>
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::operator base_type & ( )
inlinenoexcept

Returns a reference to the underlying base type.

Returns
Reference to the underlying base type.

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