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::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > > xtd::collections::generic::ienumerable< type_t > xtd::collections::generic::extensions::collection_operators< type_t, collection_t > xtd::interface xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > > xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t >

Definition

template<class key_t, class value_t, class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t, class value_t, class hasher_t = xtd::collections::generic::helpers::hasher<key_t>, class equator_t = xtd::collections::generic::helpers::equator<key_t>, class 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:67
Represents a generic collection of key/value pairs.
Definition idictionary.hpp:44
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:43
std::allocator< type_t > allocator
Represent an allocator alias.
Definition allocator.hpp:38
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:38
Header
#include <xtd/collections/generic/dictionary>
Namespace
xtd::collections::generic
Library
xtd.core
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 xtd::collections::generic::dictionary::add method throws an xtd::argument_exception when attempting to add a duplicate key.

The example uses the xtd::collections::generic::dictionary::operator [] to retrieve values, demonstrating that a xtd::collections::generic::key_not_found_exception is thrown when a requested key is not present, and showing that the value associated with a key can be replaced.

The example shows how to use the xtd::collections::generic::dictionary::try_get_vValue method as a more efficient way to retrieve values if a program often must try key values that are not in the dictionary, and it shows how to use the xtd::collections::generic::dictionary::contains_key method to test whether a key exists before calling the xtd::collections::generic::dictionary::add method.

The example shows how to enumerate the keys and values in the dictionary and how to enumerate the keys and values alone using the xtd::collections::generic::dictionary::keys property and the xtd::collections::generic::dictionary::values property.

Finally, the example demonstrates the xtd::collections::generic::dictionary::remove method.

#include <xtd/xtd>
using namespace xtd;
using namespace xtd::collections::generic;
class example {
public:
static auto main() -> void {
// 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 operator [] is another name for the indexer, so you
// can omit its name when accessing elements.
console::write_line("For key = \"rtf\", value = {0}.", xtd::as_const(open_with)["rtf"]);
// The indexer can be used to change the value associated with a key.
open_with["rtf"] = "winword.exe";
console::write_line("For key = \"rtf\", value = {0}.", xtd::as_const(open_with)["rtf"]);
// If a key does not exist, setting the indexer for that key
// adds a new key/value pair.
open_with["doc"] = "winword.exe";
// The indexer throws an exception if the requested key is not in the dictionary.
try {
console::write_line("For key = \"tif\", value = {0}.", xtd::as_const(open_with)["tif"]);
} catch (const key_not_found_exception&) {
console::write_line("key = \"tif\" is not found.");
}
// When a program often has to try keys that turn out not to
// be in the dictionary, try_get_value can be a more efficient
// way to retrieve values.
auto value = ""_s;
if (open_with.try_get_value("tif", value))
console::write_line("For key = \"tif\", value = {0}.", value);
else
console::write_line("key = \"tif\" is not found.");
// contains_key can be used to test keys before inserting them.
if (!open_with.contains_key("ht")) {
open_with.add("ht", "hypertrm.exe");
console::write_line("value added for key = \"ht\": {0}", xtd::as_const(open_with)["ht"]);
}
// When you use for each to enumerate dictionary elements,
// the elements are retrieved as key_value_pair objects.
console::write_line();
for (const key_value_pair<string, string>& kvp : open_with)
console::write_line("key = {0}, value = {1}", kvp.key(), kvp.value());
// To get the values alone, use the values property.
dictionary<string, string>::value_collection values = open_with.values();
// The elements of the value_collection are strongly typed
// with the type that was specified for dictionary values.
console::write_line();
for(const auto& s : values)
console::write_line("value = {0}", s);
// To get the keys alone, use the keys property.
// The elements of the key_collection are strongly typed
// with the type that was specified for dictionary keys.
console::write_line();
for(const string& s : keys)
console::write_line("key = {0}", s);
// Use the remove method to remove a key/value pair.
console::write_line("\nRemove(\"doc\")");
open_with.remove("doc");
if (!open_with.contains_key("doc"))
console::write_line("key \"doc\" is not found.");
}
};
startup_(example::main);
// This code produces the following output :
//
// An element with key = "txt" already exists.
// For key = "rtf", value = wordpad.exe.
// For key = "rtf", value = winword.exe.
// key = "tif" is not found.
// key = "tif" is not found.
// value added for key = "ht": hypertrm.exe
//
// key = doc, value = winword.exe
// key = rtf, value = winword.exe
// key = bmp, value = paint.exe
// key = ht, value = hypertrm.exe
// key = dib, value = paint.exe
// key = txt, value = notepad.exe
//
// value = winword.exe
// value = winword.exe
// value = paint.exe
// value = hypertrm.exe
// value = paint.exe
// value = notepad.exe
//
// key = doc
// key = rtf
// key = bmp
// key = ht
// key = dib
// key = txt
//
// Remove("doc")
// key "doc" is not found.
The exception that is thrown when one of the arguments provided to a method is not valid.
Definition argument_exception.hpp:24
typename xtd::collections::generic::idictionary< key_type, mapped_type >::key_collection key_collection
Represents the idictionary key collection type.
Definition dictionary.hpp:181
typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_collection value_collection
Represents the idictionary value collection type.
Definition dictionary.hpp:183
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:710
The exception that is thrown when the key specified for accessing an element in a collection does not...
Definition key_not_found_exception.hpp:31
Represents the standard input, output, and error streams for console applications.
Definition console.hpp:36
#define startup_(main_method)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:175
@ s
The S key.
keys
Specifies key codes and modifiers.
Definition keys.hpp:77
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
constexpr std::add_const_t< type_t > & as_const(type_t &type) noexcept
Obtains a reference to const to its argument.
Definition as_const.hpp:13
Defines a key/value pair that can be set or retrieved.
Definition key_value_pair.hpp:37
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());
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);
Examples
hashtable.cpp.

Classes

struct  equator
 Represents the dictionary equator type. More...
 
struct  hasher
 Represents the dictionary hasher type. More...
 

Public Aliases

using key_type = typename xtd::collections::generic::idictionary< key_t, value_t >::key_type
 Represents the dictionary key type.
 
using mapped_type = typename xtd::collections::generic::idictionary< key_t, value_t >::mapped_type
 Represents the dictionary mapped type.
 
using value_type = typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_type
 Represents the dictionary value type.
 
using size_type = xtd::size
 Represents the dictionary size type.
 
using difference_type = xtd::ptrdiff
 Represents the dictionary difference type.
 
using key_equal = equator
 Represents the dictionary key_equal type.
 
using allocator_type = allocator_t
 Represents the dictionary allocator type.
 
using base_value_type = std::pair< const key_t, value_t >
 Represents the dictionary base value type.
 
using base_type = std::unordered_map< key_type, mapped_type, hasher, key_equal, allocator_type >
 Represents the dictionary base type.
 
using reference = value_type &
 Represents the dictionary reference type.
 
using const_reference = const value_type &
 Represents the dictionary const reference type.
 
using pointer = typename std::allocator_traits< allocator_t >::pointer
 Represents the dictionary pointer type.
 
using const_pointer = typename std::allocator_traits< allocator_t >::const_pointer
 Represents the dictionary const pointer type.
 
using iterator = typename xtd::collections::generic::idictionary< key_type, mapped_type >::iterator
 Represents the iterator of dictionary value type.
 
using const_iterator = typename xtd::collections::generic::idictionary< key_type, mapped_type >::const_iterator
 Represents the const iterator of dictionary value type.
 
using local_iterator = typename base_type::local_iterator
 Represents the local iterator of dictionary value type.
 
using const_local_iterator = typename base_type::const_local_iterator
 Represents the const local iterator of dictionary value type.
 
using node_type = typename base_type::node_type
 Represents the dictionary node type.
 
using insert_return_type = typename base_type::insert_return_type
 Represents the dictionary insert return type.
 
using key_collection = typename xtd::collections::generic::idictionary< key_type, mapped_type >::key_collection
 Represents the idictionary key collection type.
 
using value_collection = typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_collection
 Represents the idictionary value collection type.
 

Public Constructors

 dictionary () noexcept=default
 Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the default initial capacity, and uses the default equality comparer for the key type.
 
 dictionary (const idictionary< key_t, value_t > &dictionary)
 Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::idictionary <key_t, value_t> and uses the default equality comparer for the key type.
 
 dictionary (const ienumerable< value_type > &collection)
 Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::ienumerable <type_t>.
 
template<class equality_comparer_t >
 dictionary (const equality_comparer_t &comparer)
 Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the default initial capacity, and uses the specified xtd::collections::generic::iequality_comparer<type_t>.
 
 dictionary (size_type bucket_count, const hasher_t &hash=hasher_t {}, const equator_t &equal=equator_t {}, const allocator_type &alloc=allocator_type {}) noexcept
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (size_type bucket_count, const hasher_t &hash, const allocator_type &alloc) noexcept
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
template<class equality_comparer_t >
 dictionary (const idictionary< key_t, value_t > &dictionary, const equality_comparer_t &comparer)
 Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::dictionary <key_t, value_t> and uses the specified xtd::collections::generic::iequality_comparer <type_t>.
 
template<class equality_comparer_t >
 dictionary (const ienumerable< value_type > &collection, const equality_comparer_t &comparer)
 Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::ienumerable <type_t> and uses the specified xtd::collections::generic::iequality_comparer <type_t>.
 
template<class equality_comparer_t >
 dictionary (size_t capacity, const equality_comparer_t &comparer)
 Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the specified initial capacity, and uses the specified xtd::collections::generic::iequality_comparer <type_t>.
 
template<class input_iterator_t >
 dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count=0, const hasher_t &hash=hasher_t {}, const equator_t &equal=equator_t {}, const allocator_type &alloc=allocator_type {})
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
template<class input_iterator_t >
 dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count, const allocator_type &alloc)
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
template<class input_iterator_t >
 dictionary (input_iterator_t first, input_iterator_t last, size_type bucket_count, const hasher_t &hash, const allocator_type &alloc)
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (const dictionary &other) noexcept
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (const std::unordered_map< key_t, value_t > &other)
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (const std::unordered_map< key_t, value_t > &other, const allocator_type &alloc)
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (dictionary &&other) noexcept=default
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (dictionary &&other, const allocator_type &alloc) noexcept
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (std::unordered_map< key_t, value_t > &&other) noexcept
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (std::unordered_map< key_t, value_t > &&other, const allocator_type &alloc) noexcept
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (std::initializer_list< base_value_type > init, size_type bucket_count=0, const hasher_t &hash=hasher_t {}, const equator_t &equal=equator_t {}, const allocator_type &alloc=allocator_type {})
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (std::initializer_list< base_value_type > init, size_type bucket_count, const allocator_type &alloc)
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
 dictionary (std::initializer_list< base_value_type > init, size_type bucket_count, const hasher_t &hash, const allocator_type &alloc)
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
template<class init_key_t , class init_value_t >
 dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init, size_type bucket_count=0, const hasher_t &hash=hasher_t {}, const equator_t &equal=equator_t {}, const allocator_type &alloc=allocator_type {})
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
template<class init_key_t , class init_value_t >
 dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init, size_type bucket_count, const allocator_type &alloc)
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 
template<class init_key_t , class init_value_t >
 dictionary (std::initializer_list< key_value_pair< init_key_t, init_value_t > > init, size_type bucket_count, const hasher_t &hash, const allocator_type &alloc)
 Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a variety of data sources. Optionally uses user supplied bucket_count as a minimal number of buckets to create, hash as the hash function, equal as the function to compare keys and alloc as the allocator.
 

Public Properties

const_iterator begin () const noexcept override
 Returns an iterator to the first element of the enumarable.
 
iterator begin () noexcept override
 Returns an iterator to the first element of the enumarable.
 
size_type bucket_count () const noexcept
 Gets the number of buckets in the container.
 
size_type capacity () const noexcept
 Gets the total numbers of elements the internal data structure can hold without resizing.
 
const_iterator cbegin () const noexcept override
 Returns an iterator to the first element of the enumarable.
 
const_iterator cend () const noexcept override
 Returns an iterator to the element following the last element of the enumarable.
 
const iequality_comparer< key_t > & comparer () const noexcept
 Gets the td::collections::generic::iequality_comparer <type_t> that is used to determine equality of keys for the dictionary.
 
size_type count () const noexcept override
 Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t, value_t>.
 
bool empty () const noexcept
 Checks if the container has no elements, i.e. whether begin() == end().
 
const_iterator end () const noexcept override
 Returns an iterator to the element following the last element of the enumarable.
 
iterator end () noexcept override
 Returns an iterator to the element following the last element of the enumarable.
 
bool is_read_only () const noexcept override
 Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
 
bool is_synchronized () const noexcept override
 Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe).
 
virtual const base_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>.
 
const xtd::objectsync_root () const noexcept override
 Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.
 
value_collection values () const noexcept override
 Gets a collection containing the values in the xtd::collections::generic::dictionary <key_t, value_t>.
 

Public Methods

void add (const key_t &key, const value_t value) override
 Adds an element with the provided key and value to the xtd::collections::generic::dictionary <key_t, value_t>.
 
void add (const value_type &item) override
 Adds an item to the xtd::collections::generic::icollection <type_t>.
 
const value_t & at (const key_t &key) const
 Gets the element with the specified key.
 
value_t & at (const key_t &key)
 Gets the element with the specified key.
 
local_iterator begin (size_type n)
 Returns an iterator to the beginning of the specified bucket.
 
const_local_iterator begin (size_type n) const
 Returns an iterator to the beginning of the specified bucket.
 
size_type bucket (const key_t &key) const
 Returns the index of the bucket for key key. Elements (if any) with keys equivalent to key are always found in this bucket.
 
size_type bucket_size (size_type n) const noexcept
 Returns the number of elements in the bucket with index n.
 
const_local_iterator cbegin (size_type n) const
 Returns an iterator to the beginning of the specified bucket.
 
const_local_iterator cend (size_type n) const
 Returns an iterator to the end of the specified bucket.
 
void clear () noexcept override
 Removes all keys and values from the xtd::collections::generic::dictionary <key_t, value_t>.
 
bool contains (const key_t &key) const noexcept
 Checks if the container contains element with specific key.
 
template<class contains_key_t >
bool contains (const contains_key_t &x) const
 Checks if the container contains element with specific key.
 
bool contains (const value_type &item) const noexcept override
 Determines whether an element is in the xtd::collections::generic::dictionary <key_t, value_t>.
 
bool contains_key (const key_t &key) const noexcept override
 Determines whether the xtd::collections::generic::dictionary <key_t, value_t> contains the specified key.
 
bool contains_value (const value_t &value) const noexcept
 
void copy_to (xtd::array< value_type > &array, xtd::size array_index) const override
 Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.
 
template<class ... args_t>
key_value_pair< iterator, bool > emplace (args_t &&...args)
 Constructs element in-place.
 
template<class ... args_t>
iterator emplace_hint (iterator hint, args_t &&...args)
 constructs elements in-place using a hint
 
local_iterator end (size_type n)
 Returns an iterator to the end of the specified bucket.
 
const_local_iterator end (size_type n) const
 Returns an iterator to the end of the specified bucket.
 
xtd::size ensure_capacity (xtd::size capacity) noexcept
 Ensures that the dictionary can hold up to a specified number of entries without any further expansion of its backing storage.
 
key_value_pair< iterator, iteratorequal_range (const key_t &key)
 Returns range of elements matching a specific key.
 
template<class equal_range_key_t >
key_value_pair< const_iterator, const_iteratorequal_range (const equal_range_key_t &key) const
 Returns range of elements matching a specific key.
 
template<class equal_range_key_t >
key_value_pair< iterator, iteratorequal_range (const equal_range_key_t &x)
 Returns range of elements matching a specific key.
 
key_value_pair< const_iterator, const_iteratorequal_range (const key_t &x) const
 Returns range of elements matching a specific key.
 
iterator erase (const_iterator pos)
 Erases elements.
 
iterator erase (const_iterator first, const_iterator last)
 Erases elements.
 
size_type erase (const key_t &key)
 Erases elements.
 
node_type extract (const_iterator position) noexcept
 Extracts nodes from the container.
 
node_type extract (const key_t k)
 Extracts nodes from the container.
 
const_iterator find (const key_t &key) const
 Finds element with specific key.
 
const_iterator find (const key_t &key)
 Finds element with specific key.
 
template<class find_key_t >
const_iterator find (const find_key_t &x) const
 Finds element with specific key.
 
template<class find_key_t >
iterator find (const find_key_t &x)
 Finds element with specific key.
 
allocator_type get_allocator () const noexcept
 Returns the allocator associated with the container.
 
enumerator< value_typeget_enumerator () const noexcept override
 Returns an enumerator that iterates through the xtd::collections::generic::dictionary <key_t, value_t>.
 
hasher hash_function () const
 Returns function used to hash the keys.
 
key_value_pair< iterator, bool > insert (const value_type &value)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
key_value_pair< iterator, bool > insert (value_type &&value)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
template<class type_t >
key_value_pair< iterator, bool > insert (type_t &&value)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
iterator insert (const_iterator hint, const value_type &value)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
iterator insert (const_iterator hint, value_type &&value)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
template<class type_t >
iterator insert (const_iterator hint, type_t &&value)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
template<class input_iterator_t >
void insert (input_iterator_t first, input_iterator_t last)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
void insert (std::initializer_list< base_value_type > ilist)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
template<class init_key_t , class init_value_t >
void insert (std::initializer_list< key_value_pair< init_key_t, init_value_t > > ilist)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
insert_return_type insert (node_type &&nh)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
iterator insert (const_iterator hint, node_type &&nh)
 Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.
 
template<class type_t >
key_value_pair< iterator, bool > insert_or_assign (const key_t &k, type_t &&obj)
 Inserts an element or assigns to the current element if the key already exists.
 
template<class type_t >
key_value_pair< iterator, bool > insert_or_assign (key_t &&k, type_t &&obj)
 Inserts an element or assigns to the current element if the key already exists.
 
template<class type_t >
iterator insert_or_assign (const_iterator hint, const key_t &k, type_t &&obj)
 Inserts an element or assigns to the current element if the key already exists.
 
template<class type_t >
iterator insert_or_assign (const_iterator hint, key_t &&k, type_t &&obj)
 Inserts an element or assigns to the current element if the key already exists.
 
key_equal key_eq () const
 Returns the function used to compare keys for equality.
 
template<class source_hasher_t , class source_equator_t >
void merge (dictionary< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source)
 Splices nodes from another container.
 
template<class source_hasher_t , class source_equator_t >
void merge (dictionary< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source)
 Splices nodes from another container.
 
template<class source_hasher_t , class source_equator_t >
void merge (std::unordered_map< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source)
 Splices nodes from another container.
 
template<class source_hasher_t , class source_equator_t >
void merge (std::unordered_map< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source)
 Splices nodes from another container.
 
template<class source_hasher_t , class source_equator_t >
void merge (std::unordered_multimap< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source)
 Splices nodes from another container.
 
template<class source_hasher_t , class source_equator_t >
void merge (std::unordered_multimap< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source)
 Splices nodes from another container.
 
void rehash (size_type count)
 Reserves at least the specified number of buckets and regenerates the hash table.
 
bool remove (const key_t &key) noexcept override
 Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t, value_t>.
 
bool remove (const value_type &item) noexcept override
 Removes the first occurrence of a specific object from the xtd::collections::generic::dictionary <key_t, value_t>.
 
bool remove (const key_t &key, value_t &value) noexcept
 Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t, value_t>, and copies the element to the value parameter.
 
void reserve (size_type count)
 Reserves space for at least the specified number of elements and regenerates the hash table.
 
void swap (dictionary &other) noexcept
 Swaps the contents.
 
xtd::string to_string () const noexcept override
 Gets a string that represents the current object.
 
void trim_excess (size_type capacity)
 Sets the capacity of this dictionary to hold up a specified number of entries without any further expansion of its backing storage.
 
void trim_excess ()
 Sets the capacity of this dictionary to what it would be if it had been originally initialized with all its entries.
 
bool try_add (const key_t &key, const value_t value) noexcept
 Attempts to add the specified key and value to the dictionary.
 
template<class ... args_t>
key_value_pair< iterator, bool > try_emplace (const key_t &k, args_t &&... args)
 Inserts in-place if the key does not exist, does nothing if the key exists.
 
template<class ... args_t>
key_value_pair< iterator, bool > try_emplace (key_t &&k, args_t &&... args)
 Inserts in-place if the key does not exist, does nothing if the key exists.
 
template<class ... args_t>
iterator try_emplace (const_iterator hint, const key_t &k, args_t &&... args)
 Inserts in-place if the key does not exist, does nothing if the key exists.
 
template<class ... args_t>
iterator try_emplace (const_iterator hint, key_t &&k, args_t &&... args)
 Inserts in-place if the key does not exist, does nothing if the key exists.
 
bool try_get_value (const key_t &key, value_t &value) const override
 Gets the value associated with the specified key.
 

Public Operators

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<class init_key_t , class 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 = typename xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >::value_type
 Represents the xtd::collections::generic::idictionary value type.
 
using iterator = typename xtd::collections::generic::icollection< value_type >::iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
 
using const_iterator = typename xtd::collections::generic::icollection< value_type >::const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
 
using key_collection = xtd::collections::generic::list< key_type >
 Represents the idictionary key collection type.
 
using value_collection = xtd::collections::generic::list< mapped_type >
 Represents the idictionary value collection type.
 
- Public Types inherited from xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >
using value_type = typename xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > >::value_type
 Represents the xtd::collections::generic::icollection value type.
 
using iterator = typename xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > >::iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
 
using const_iterator = typename xtd::collections::generic::ienumerable< xtd::collections::generic::key_value_pair< key_t, value_t > >::const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
 
- Public Types inherited from xtd::collections::generic::ienumerable< type_t >
using value_type = type_t
 Represents the xtd::collections::generic::ienumerable value type.
 
using iterator = typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
 
using const_iterator = typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
 
- Public Types inherited from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >
using iterator = enumerable_iterator
 Represents the iterator of enumarable value type.
 
using const_iterator = const enumerable_iterator
 Represents the const iterator of enumarable value type.
 
- Public Types inherited from xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t >
using enumerable_type = ienumerable< type_t >
 Represents the ienumerable enumerable type.
 
using source_type = type_t
 Represents the ienumerable source type.
 
using ienumerable = typename xtd::linq::enumerable::ienumerable< type_t >
 Represents the ienumerable value type.
 
using list = typename xtd::linq::enumerable::list< type_t >
 Represents the list value type.
 
- 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 xtd::size get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<class object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
- Public Member Functions inherited from xtd::collections::generic::idictionary< key_t, value_t >
- Public Member Functions inherited from xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >
virtual void add (const xtd::collections::generic::key_value_pair< key_t, value_t > &item)=0
 Adds an item to the xtd::collections::generic::icollection <type_t>.
 
virtual bool contains (const xtd::collections::generic::key_value_pair< key_t, value_t > &item) const noexcept=0
 Determines whether the xtd::collections::generic::icollection <type_t> contains a specific value.
 
virtual void copy_to (xtd::array< xtd::collections::generic::key_value_pair< key_t, value_t > > &array, xtd::size array_index) const=0
 Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.
 
virtual bool remove (const xtd::collections::generic::key_value_pair< key_t, value_t > &item)=0
 Removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
 
- Public Member Functions inherited from xtd::collections::generic::ienumerable< type_t >
- Public Member Functions inherited from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >
- Public Member Functions inherited from xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t >
type_t aggregate (const std::function< type_t(const type_t &, const type_t &)> &func) const
 Applies an accumulator function over a sequence.
 
type_t aggregate (const type_t &seed, const std::function< type_t(const type_t &, const type_t &)> &func) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
 
accumulate_t aggregate (const accumulate_t &seed, const std::function< accumulate_t(const type_t &, const accumulate_t &)> &func) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value.
 
type_t aggregate (const type_t &seed, const std::function< type_t(const type_t &, const type_t &)> &func, const std::function< type_t(const type_t &)> &result_selector) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
 
result_t aggregate (const accumulate_t &seed, const std::function< accumulate_t(const type_t &, const accumulate_t &)> &func, const std::function< result_t(const accumulate_t &)> &result_selector) const
 Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value.
 
bool all (const std::function< bool(const type_t &)> &predicate) const
 Determines whether all elements of a sequence satisfy a condition.
 
bool any () const noexcept
 Determines whether a sequence contains any elements.
 
bool any (const std::function< bool(const type_t &)> &predicate) const
 Determines whether any element of a sequence satisfies a condition.
 
const ienumerable< type_t > & append (const type_t &element) const noexcept
 Appends a value to the end of the sequence.
 
const ienumerable< type_t > & as_enumerable () const noexcept
 Returns the input typed as xtd::collection::generic::ienumerable <type_t>.
 
auto average () const noexcept
 Computes the average of a sequence of source_t values.
 
const ienumerable< result_t > & cast () const noexcept
 Casts the elements of an xtd::collection::generic::ienumerable to the specified type.
 
const ienumerable< xtd::array< type_t > > & chunk (size_t size) const
 Splits the elements of a sequence into chunks of size at most size.
 
const ienumerable< type_t > & concat (const ienumerable< type_t > &second) const noexcept
 Concatenates two sequences.
 
bool contains (const type_t &value) const noexcept
 Determines whether a sequence contains a specified element by using the default equality comparer.
 
bool contains (const type_t &value, const xtd::collections::generic::iequality_comparer< type_t > &comparer) const noexcept
 Determines whether a sequence contains a specified element by using a specified equality comparer.
 
size_t count () const noexcept
 Returns the number of elements in current sequence.
 
size_t count (const std::function< bool(const type_t &)> &predicate) const noexcept
 Returns a number that represents how many elements in the specified sequence satisfy a condition.
 
const ienumerable< key_value_pair< key_t, xtd::size > > & count_by (const std::function< key_t(const type_t &)> &key_selector) const noexcept
 Returns the count of elements in the current sequence grouped by key.
 
const ienumerable< key_value_pair< key_t, xtd::size > > & count_by (const std::function< key_t(const type_t &)> &key_selector, const iequality_comparer< key_t > &key_comparer) const noexcept
 Returns the count of elements in the current sequence grouped by key.
 
const ienumerable< type_t > & default_if_empty () const noexcept
 Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty.
 
const ienumerable< type_t > & default_if_empty (const type_t &default_value) const noexcept
 Returns the elements of the specified sequence or the specified value in a singleton collection if the current sequence is empty.
 
type_t first_or_default (const std::function< bool(const type_t &)> &predicate, const type_t &default_value) const noexcept
 Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
 
type_t first_or_default (const std::function< bool(const type_t &)> &predicate) const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
type_t first_or_default (const type_t default_value) const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
type_t first_or_default () const noexcept
 Returns the first element of the sequence that satisfies a condition or a default value if no such element is found.
 
const ienumerable< result_t > & select (const std::function< result_t(const type_t &)> &selector) const
 Projects each element of a sequence into a new form.
 
const ienumerable< type_t > & select (const std::function< type_t(const type_t &)> &selector) const
 Projects each element of a sequence into a new form.
 
const ienumerable< result_t > & select (const std::function< result_t(const type_t &, size_t index)> &selector) const
 Projects each element of a sequence into a new form by incorporating the element's index.
 
const ienumerable< type_t > & select (const std::function< type_t(const type_t &, size_t index)> &selector) const
 Projects each element of a sequence into a new form by incorporating the element's index.
 
const list< type_t > & to_list () const noexcept
 Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
 
const ienumerable< type_t > & where (const std::function< bool(const type_t &)> &predicate) const
 Filters a sequence of values based on a predicate.
 
const ienumerable< type_t > & where (const std::function< bool(const type_t &, size_t)> &predicate) const
 Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function.
 
- Public Member Functions inherited from xtd::collections::generic::extensions::collection_operators< type_t, collection_t >
virtual collection_t & operator<< (const type_t &item)
 The shift left operator adds an item to the xtd::collections::generic::icollection <type_t>.
 
virtual collection_t & operator>> (const type_t &item)
 The shift right operator removes tthe first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
 
- Static Public Member Functions inherited from xtd::object
template<class object_a_t , class object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<class object_a_t , class object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 
- Static Public Member Functions inherited from xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >
static target_collection_t::const_iterator to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::iterator to_iterator (typename source_collection_t::iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::const_iterator to_iterator (typename source_collection_t::const_iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 
static target_collection_t::iterator to_iterator (typename source_collection_t::iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept
 Converts source iterator to target iterator.
 

Member Typedef Documentation

◆ key_type

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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.

◆ key_equal

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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

Represents the dictionary key_equal type.

◆ allocator_type

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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.");
}
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...

◆ dictionary() [2/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 idictionary< key_t, value_t > &  dictionary)
inline

Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::idictionary <key_t, value_t> and uses the default equality comparer for the key type.

Parameters
dictionaryThe xtd::collections::generic::idictionary <key_t, value_t> whose elements are copied to the new xtd::collections::generic::dictionary <key_t, value_t>.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
Remarks
Every key in a xtd::collections::generic::dictionary <key_t, value_t> must be unique according to the default equality comparer; likewise, every key in the source dictionary must also be unique according to the default equality comparer.
The initial capacity of the new xtd::collections::generic::dictionary <key_t, value_t> is large enough to contain all the elements in dictionary.
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, xtd::collections::generic::equality_comparer::default_equality_comparer. If type key_t implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation. Alternatively, you can specify an implementation of the xtd::collections::generic::iequality_comparer <type_t> generic interface by using a constructor that accepts a comparer parameter.
This constructor is an O(n) operation, where n is the number of elements in dictionary.
Examples
The following code example shows how to use the xtd::collections::generic::dictionary <key_t, value_t>(xtd::collections::generic::iequality_comparer <key_t>) constructor to initialize a xtd::collections::generic::dictionary <key_t, value_t> with sorted content from another dictionary. The code example creates a xtd::collections::generic::sorted_dictionary <key_t, value_t> and populates it with data in random order, then passes the xtd::collections::generic::sorted_dictionary <key_t, value_t> to the xtd::collections::generic::dictionary <key_t, value_t>(xtd::collections::generic::iequality_comparer <key_t>) constructor, creating a xtd::collections::generic::dictionary <key_t, value_t> that is sorted. This is useful if you need to build a sorted dictionary that at some point becomes static; copying the data from a xtd::collections::generic::sorted_dictionary <key_t, value_t> to a xtd::collections::generic::dictionary <key_t, value_t> improves retrieval speed.
#include <xtd/xtd>
using namespace xtd;
using namespace xtd::collections::generic;
class example {
public:
static auto main() -> void {
// Create a new sorted dictionary of strings, with string keys.
auto open_with = sorted_dictionary<string, string> {};
// Add some elements to the dictionary.
open_with.add("txt", "notepad.exe");
open_with.add("bmp", "paint.exe");
open_with.add("dib", "paint.exe");
open_with.add("rtf", "wordpad.exe");
// Create a dictionary of strings with string keys, and
// initialize it with the contents of the sorted dictionary.
auto copy = dictionary<string, string>(open_with);
// List the contents of the copy.
console::write_line();
for(const key_value_pair<string, string>& kvp : copy)
console::write_line("key = {0}, value = {1}", kvp.key(), kvp.value());
}
};
startup_(example::main);
// This code produces the following output :
//
// key = txt, value = notepad.exe
// key = bmp, value = paint.exe
// key = dib, value = paint.exe
// key = rtf, value = wordpad.exe

◆ dictionary() [3/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 ienumerable< value_type > &  collection)
inline

Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::ienumerable <type_t>.

Parameters
collectionThe xtd::collections::generic::ienumerable <type_t> whose elements are copied to the new xtd::collections::generic::dictionary <key_t, value_t>
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.

◆ dictionary() [4/25]

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

Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the default initial capacity, and uses the specified xtd::collections::generic::iequality_comparer<type_t>.

Parameters
comparerThe xtd::collections::generic::iequality_comparer<type_t> implementation to use when comparing keys.
Remarks
Use this constructor with the case-insensitive string comparers provided by the xtd::string_comparer class to create dictionaries with case-insensitive string keys.
Every key in a xtd::collections::generic::dictionary <key_t, value_t> must be unique according to the specified comparer.
xtd::collections::generic::dictionary <key_t, value_t> requires an equality implementation to determine whether keys are equal. If type key_t implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.

◆ dictionary() [5/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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_t &  hash = hasher_t {},
const equator_t &  equal = equator_t {},
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.
Every key in a xtd::collections::generic::dictionary <key_t, value_t> must be unique according to the specified comparer.
The capacity of a xtd::collections::generic::dictionary <key_t, value_t> is the number of elements that can be added to the xtd::collections::generic::dictionary <key_t, value_t> before resizing is necessary. 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.
If the size of the collection can be estimated, specifying 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>.
xtd::collections::generic::dictionary <key_t, value_t> requires an equality implementation to determine whether keys are equal. If type key_t implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [6/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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_t &  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.
Every key in a xtd::collections::generic::dictionary <key_t, value_t> must be unique according to the specified comparer.
The capacity of a xtd::collections::generic::dictionary <key_t, value_t> is the number of elements that can be added to the xtd::collections::generic::dictionary <key_t, value_t> before resizing is necessary. 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.
If the size of the collection can be estimated, specifying 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>.
xtd::collections::generic::dictionary <key_t, value_t> requires an equality implementation to determine whether keys are equal. If type key_t implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [7/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class equality_comparer_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( const idictionary< key_t, value_t > &  dictionary,
const equality_comparer_t &  comparer 
)
inline

Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::dictionary <key_t, value_t> and uses the specified xtd::collections::generic::iequality_comparer <type_t>.

Parameters
dictionaryThe xtd::collections::generic::dictionary <key_t, value_t> whose elements are copied to the new xtd::collections::generic::dictionary <key_t, value_t>.
comparerThe xtd::collections::generic::iequality_comparer <type_t> implementation to use when comparing keys.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
Remarks
Use this constructor with the case-insensitive string comparers provided by the xtd::string_comparer class to create dictionaries with case-insensitive string keys.
Every key in a xtd::collections::generic::dictionary <key_t, value_t> must be unique according to the specified comparer; likewise, every key in the source dictionary must also be unique according to the specified comparer.
Note
For example, duplicate keys can occur if comparer is one of the case-insensitive string comparers provided by the xtd::string_comparer class and dictionary does not use a case-insensitive comparer key.
Remarks
The initial capacity of the new xtd::collections::generic::dictionary <key_t, value_t> is large enough to contain all the elements in dictionary.
xtd::collections::generic::dictionary <key_t, value_t> requires an equality implementation to determine whether keys are equal. If type key_t implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
This constructor is an O(n) operation, where n is the number of elements in dictionary.

◆ dictionary() [8/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class equality_comparer_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( const ienumerable< value_type > &  collection,
const equality_comparer_t &  comparer 
)
inline

Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that contains elements copied from the specified xtd::collections::generic::ienumerable <type_t> and uses the specified xtd::collections::generic::iequality_comparer <type_t>.

Parameters
collectionThe xtd::collections::generic::ienumerable <type_t> whose elements are copied to the new xtd::collections::generic::dictionary <key_t, value_t>.
comparerThe xtd::collections::generic::iequality_comparer <type_t> implementation to use when comparing keys.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.

◆ dictionary() [9/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class equality_comparer_t >
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::dictionary ( size_t  capacity,
const equality_comparer_t &  comparer 
)
inline

Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that is empty, has the specified initial capacity, and uses the specified xtd::collections::generic::iequality_comparer <type_t>.

Parameters
capacityThe initial number of elements that the xtd::collections::generic::dictionary <key_t, value_t> can contain.
comparerThe xtd::collections::generic::iequality_comparer <type_t> implementation to use when comparing keys.
Remarks
Use this constructor with the case-insensitive string comparers provided by the xtd::string_comparer class to create dictionaries with case-insensitive string keys.
Every key in a xtd::collections::generic::dictionary <key_t, value_t> must be unique according to the specified comparer; likewise, every key in the source dictionary must also be unique according to the specified comparer.
The capacity of a xtd::collections::generic::dictionary <key_t, value_t> is the number of elements that can be added to the xtd::collections::generic::dictionary <key_t, value_t> before resizing is necessary. 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.
If the size of the collection can be estimated, specifying 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>.
xtd::collections::generic::dictionary <key_t, value_t> requires an equality implementation to determine whether keys are equal. If type TKey implements the xtd::iequatable <type_t> generic interface, the default equality comparer uses that implementation.
This constructor is an O(1) operation.
xtd::collections::generic::dictionary::capacity and xtd::collections::generic::dictionary::bucket_count are equivalent properties.

◆ dictionary() [10/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class 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_t &  hash = hasher_t {},
const equator_t &  equal = equator_t {},
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
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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
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.
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [11/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class 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 
)
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
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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
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.
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [12/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class 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_t &  hash,
const allocator_type alloc 
)
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
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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
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.
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [13/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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() [14/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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)
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
otherAnother container to be used as source to initialize the elements of the container with.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
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() [15/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 
)
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
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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
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() [16/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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() [17/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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() [18/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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() [19/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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() [20/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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_t &  hash = hasher_t {},
const equator_t &  equal = equator_t {},
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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
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() [21/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [22/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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_t &  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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [23/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class init_key_t , class 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_t &  hash = hasher_t {},
const equator_t &  equal = equator_t {},
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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [24/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class init_key_t , class 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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ dictionary() [25/25]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class init_key_t , class 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_t &  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.
Exceptions
xtd::argument_exception`dictionary` contains one or more duplicate keys.
Remarks
Initializer-list constructor. Constructs the container with the contents of the initializer list init, same as
dictionary(init.begin(), init.end())
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

Member Function Documentation

◆ begin() [1/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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, xtd::collections::generic::ienumerable< type_t > >.

◆ begin() [2/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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, xtd::collections::generic::ienumerable< type_t > >.

◆ bucket_count()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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.
Remarks
xtd::collections::generic::dictionary::bucket_count and xtd::collections::generic::dictionary::capacity are equivalent properties.

◆ capacity()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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.
Remarks
xtd::collections::generic::dictionary::capacity and xtd::collections::generic::dictionary::bucket_count are equivalent properties.

◆ cbegin() [1/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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, xtd::collections::generic::ienumerable< type_t > >.

◆ cend() [1/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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, xtd::collections::generic::ienumerable< type_t > >.

◆ comparer()

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

Gets the td::collections::generic::iequality_comparer <type_t> that is used to determine equality of keys for the dictionary.

Returns
The xtd::collections::generic::iequality_comparer <type_t> generic interface implementation that is used to determine equality of keys for the current xtd::collections::generic::dictionary <key_t, value_t> and to provide hash values for the keys.
Remarks
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 td::collections::generic::iequality_comparer <type_t> generic interface by using a constructor that accepts a comparer parameter; if you do not specify one, the default generic equality comparer td::collections::generic::equality_comparer::default_equality_comparer is used.

◆ count()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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
inlineoverridevirtualnoexcept

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.

Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.

◆ empty()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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, xtd::collections::generic::ienumerable< type_t > >.

◆ end() [2/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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, xtd::collections::generic::ienumerable< type_t > >.

◆ is_read_only()

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

Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.

Returns
true if the xtd::collections::generic::icollection <type_t> is read-only; otherwise, false.
Remarks
A collection that is read-only does not allow the addition or removal of elements after the collection is created. Note that read-only in this context does not indicate whether individual elements of the collection can be modified, since the xtd::collections::generic::icollection <type_t> interface only supports addition and removal operations. For example, the IsReadOnly property of an array that is cast or converted to an xtd::collections::generic::icollection <type_t> object returns true, even though individual array elements can be modified.

Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.

◆ is_synchronized()

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

Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe).

Returns
true if access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe); otherwise, false.
Remarks
xtd::collections::generic::icollection::sync_root returns an object, which can be used to synchronize access to the xtd::collections::generic::icollection <type_t>.
Most collection classes in the xtd::collections namespace also implement a synchronized method, which provides a synchronized wrapper around the underlying collection.
Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.
The following code example shows how to lock the collection using the xtd::collections::generic::icollection::sync_root property during the entire enumeration.
icollection& my_collection = some_collection;
lock_(my_collection.sync_root()) {
for (auto item : my_collection) {
// Insert your code here.
}
}
Defines methods to manipulate generic collections.
Definition icollection.hpp:45
virtual const xtd::object & sync_root() const noexcept=0
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollecti...
#define lock_(object)
The lock_ keyword marks a statement block as a critical section by obtaining the mutual-exclusion loc...
Definition lock.hpp:85

Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.

◆ items() [1/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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.

◆ sync_root()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
const xtd::object & xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::sync_root ( ) const
inlineoverridevirtualnoexcept

Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.

Returns
An object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.
Remarks
For collections whose underlying store is not publicly available, the expected implementation is to return the current instance. Note that the pointer to the current instance might not be sufficient for collections that wrap other collections; those should return the underlying collection's sync_root property.
Most collection classes in the xts::.collections namespace also implement a synchronized method, which provides a synchronized wrapper around the underlying collection. However, derived classes can provide their own synchronized version of the collection using the xtd::collections::generic::icollection::sync_root property. The synchronizing code must perform operations on the xtd::collections::generic::icollection::sync_root property of the collection, not directly on the collection. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the collection instance.
In the absence of a synchronized method on a collection, the expected usage for the xtd::collections::generic::icollection::sync_root looks as follows:
icollection& my_collection = some_collection;
lock_(my_collection.sync_root()) {
// Some operation on the collection, which is now thread safe.
}
@encode
@remarks Enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads can still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads.
@remarks The following code example shows how to lock the collection using the xtd::collections::generic::icollection::sync_root property during the entire enumeration.
@code
icollection& my_collection = some_collection;
lock_(my_collection.sync_root()) {
for (auto item : my_collection) {
// Insert your code here.
}
}
Defines the base class for predefined exceptions in the xtd namespace.
Definition exception.hpp:28
Provides a mechanism that synchronizes access to objects with xtd::threading::monitor.
Definition lock_guard.hpp:32
bool is(std::any value)
Checks if the result of an expression is compatible with a given type.
Definition is.hpp:365
@ a
The A key.
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:40

Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.

◆ values()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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() [1/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 >.

◆ add() [2/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 value_type item)
inlineoverride

Adds an item to the xtd::collections::generic::icollection <type_t>.

Parameters
itemThe object to add to the xtd::collections::generic::icollection <type_t>.
Exceptions
xtd::not_supported_exceptionThe xtd::collections::generic::icollection <type_t> is read-only.

◆ at() [1/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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.

◆ begin() [3/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
local_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::begin ( size_type  n)
inline

Returns an iterator to the beginning of the specified bucket.

Parameters
nThe index of the bucket to access.
Returns
Iterator to the first element.
Remarks
Returns an iterator to the first element of the bucket with index n.

◆ begin() [4/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
const_local_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::begin ( size_type  n) const
inline

Returns an iterator to the beginning of the specified bucket.

Parameters
nThe index of the bucket to access.
Returns
Iterator to the first element.
Remarks
Returns an iterator to the first element of the bucket with index n.

◆ bucket()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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.

◆ cbegin() [2/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
const_local_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::cbegin ( size_type  n) const
inline

Returns an iterator to the beginning of the specified bucket.

Parameters
nThe index of the bucket to access.
Returns
Iterator to the first element.
Remarks
Returns an iterator to the first element of the bucket with index n.

◆ cend() [2/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
const_local_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::cend ( size_type  n) const
inline

Returns an iterator to the end of the specified bucket.

Parameters
nThe index of the bucket to access.
Returns
Iterator to the element following the last element.
Remarks
Returns an iterator to the element following the last element of the bucket with index n. This element acts as a placeholder, attempting to access it results in undefined behavior.

◆ clear()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 ( )
inlineoverridevirtualnoexcept

Removes all keys and values from the xtd::collections::generic::dictionary <key_t, value_t>.

Remarks
The xtd::collections::generic::dictionary::count property is set to 0, and references to other objects from elements of the collection are also released. The capacity remains unchanged.

Implements xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< key_t, value_t > >.

◆ contains() [1/3]

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

Checks if the container contains element with specific key.

Remarks
Checks if there is an element with key equivalent to key in the container.
Examples
hashtable.cpp.

◆ contains() [2/3]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class contains_key_t >
bool xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::contains ( const contains_key_t &  x) const
inline

Checks if the container contains element with specific key.

Remarks
Checks if there is an element with key that compares equivalent to the value x. This overload participates in overload resolution only if hasher_t::is_transparent and equator_t::is_transparent are valid and each denotes a type. This assumes that such hasher_t is callable with both contains_key_t and key_t type, and that the equator_t is transparent, which, together, allows calling this function without constructing an instance of key_t.

◆ contains() [3/3]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
bool xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::contains ( const value_type item) const
inlineoverridenoexcept

Determines whether an element is in the xtd::collections::generic::dictionary <key_t, value_t>.

Parameters
itemThe object to be added to the end of the xtd::collections::generic::dictionary <key_t, value_t>.
Returns
true if the xtd::collections::generic::dictionary <key_t, value_t> contains an element with the specified item ; otherwise, false.

◆ contains_key()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
bool xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::contains_key ( const key_t &  key) const
inlineoverridevirtualnoexcept

Determines whether the xtd::collections::generic::dictionary <key_t, value_t> contains the specified key.

Parameters
Thekey to locate in the xtd::collections::generic::dictionary <key_t, value_t>.
Returns
true if the xtd::collections::generic::dictionary <key_t, value_t> contains an element with the specified key ; otherwise, false.
Remarks
This method approaches an O(1) operation.

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

◆ copy_to()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::copy_to ( xtd::array< value_type > &  array,
xtd::size  array_index 
) const
inlineoverride

Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.

Parameters
arrayThe one-dimensional xtd::array that is the destination of the elements copied from xtd::collections::generic::icollection <type_t>. The xtd::array must have zero-based indexing.
array_indexThe zero-based index in array at which copying begins.
Exceptions
xtd::argument_exceptionThe number of elements in the source xtd::collections::generic::icollection <type_t> is greater than the available space from `array_index` to the end of the destination `array`.

◆ emplace()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class ... args_t>
key_value_pair< iterator, bool > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::emplace ( args_t &&...  args)
inline

Constructs element in-place.

Parameters
argsThe arguments to forward to the constructor of the element.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.
Remarks
Inserts a new element into the container constructed in-place with the given args, if there is no element with the key in the container.
The constructor of the new element (i.e. std::pair<const key_t, value_t>) is called with exactly the same arguments as supplied to emplace, forwarded via std::forward<args_t>(args).... The element may be constructed even if there already is an element with the key in the container, in which case the newly constructed element will be destroyed immediately (see xtd::collections::generic::dictionary::try_emplace if this behavior is undesirable).
Careful use of emplace allows the new element to be constructed while avoiding unnecessary copy or move operations.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ emplace_hint()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class ... args_t>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::emplace_hint ( iterator  hint,
args_t &&...  args 
)
inline

constructs elements in-place using a hint

Parameters
hintThe iterator, used as a suggestion as to where to insert the new element.
argsThe arguments to forward to the constructor of the element.
Returns
An iterator to the inserted element, or to the element that prevented the insertion.
Remarks
Inserts a new element into the container, using hint as a suggestion where the element should go.
The constructor of the element type (value_type, that is, std::pair<const key_t, value_t>) is called with exactly the same arguments as supplied to the function, forwarded with std::forward<args_t>(args)....
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ end() [3/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
local_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::end ( size_type  n)
inline

Returns an iterator to the end of the specified bucket.

Parameters
nThe index of the bucket to access.
Returns
Iterator to the element following the last element.
Remarks
Returns an iterator to the element following the last element of the bucket with index n. This element acts as a placeholder, attempting to access it results in undefined behavior.

◆ end() [4/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
const_local_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::end ( size_type  n) const
inline

Returns an iterator to the end of the specified bucket.

Parameters
nThe index of the bucket to access.
Returns
Iterator to the element following the last element.
Remarks
Returns an iterator to the element following the last element of the bucket with index n. This element acts as a placeholder, attempting to access it results in undefined behavior.

◆ ensure_capacity()

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

Ensures that the dictionary can hold up to a specified number of entries without any further expansion of its backing storage.

Parameters
capacityThe number of entries.
Returns
The current capacity of the xtd::collections::generic::dictionary <key_t, value_t>.

◆ equal_range() [1/4]

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

Returns range of elements matching a specific key.

Parameters
keyThe key value to compare the elements to.
Returns
xtd::collections::generic::key_value_pair containing a pair of iterators defining the wanted range. If there are no such elements, past-the-end (see xtd::collections::generic::dictionary::end) iterators are returned as both elements of the pair.
Remarks
Returns a range containing all elements with key key in the container. The range is defined by two iterators, the first pointing to the first element of the wanted range and the second pointing past the last element of the range.

◆ equal_range() [2/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class equal_range_key_t >
key_value_pair< const_iterator, const_iterator > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::equal_range ( const equal_range_key_t &  key) const
inline

Returns range of elements matching a specific key.

Parameters
keyThe key value to compare the elements to.
Returns
xtd::collections::generic::key_value_pair containing a pair of iterators defining the wanted range. If there are no such elements, past-the-end (see xtd::collections::generic::dictionary::end) iterators are returned as both elements of the pair.
Remarks
Returns a range containing all elements with key key in the container. The range is defined by two iterators, the first pointing to the first element of the wanted range and the second pointing past the last element of the range.

◆ equal_range() [3/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class equal_range_key_t >
key_value_pair< iterator, iterator > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::equal_range ( const equal_range_key_t &  x)
inline

Returns range of elements matching a specific key.

Parameters
xA value of any type that can be transparently compared with a key.
Returns
xtd::collections::generic::key_value_pair containing a pair of iterators defining the wanted range. If there are no such elements, past-the-end (see xtd::collections::generic::dictionary::end) iterators are returned as both elements of the pair.
Remarks
Returns a range containing all elements in the container with key equivalent to x. This overload participates in overload resolution only if hasher_t::is_transparent and equator_t::is_transparent are valid and each denotes a type. This assumes that such Hash is callable with both equal_range_key_t and key_t type, and that the equator_t is transparent, which, together, allows calling this function without constructing an instance of equal_range_key_t.

◆ equal_range() [4/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
key_value_pair< const_iterator, const_iterator > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::equal_range ( const key_t &  x) const
inline

Returns range of elements matching a specific key.

Parameters
xA value of any type that can be transparently compared with a key.
Returns
xtd::collections::generic::key_value_pair containing a pair of iterators defining the wanted range. If there are no such elements, past-the-end (see xtd::collections::generic::dictionary::end) iterators are returned as both elements of the pair.
Remarks
Returns a range containing all elements in the container with key equivalent to x. This overload participates in overload resolution only if hasher_t::is_transparent and equator_t::is_transparent are valid and each denotes a type. This assumes that such Hash is callable with both equal_range_key_t and key_t type, and that the equator_t is transparent, which, together, allows calling this function without constructing an instance of key_t.

◆ erase() [1/3]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::erase ( const_iterator  pos)
inline

Erases elements.

Parameters
posThe iterator to the element to remove.
Returns
The iterator following the last removed element.
Remarks
Removes specified elements from the container. The order of the remaining elements is preserved. (This makes it possible to erase individual elements while iterating through the container.)
Removes the element at pos.
References and iterators to the erased elements are invalidated. Other iterators and references are not invalidated.
The iterator pos must be valid and dereferenceable. Thus the xtd::collections::generic::dictionary::end iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos.
Examples
hashtable.cpp.

◆ erase() [2/3]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::erase ( const_iterator  first,
const_iterator  last 
)
inline

Erases elements.

Parameters
firstThe first iterator of the range of elements to remove.
lastThe last iterator of the range of elements to remove.
Returns
The iterator following the last removed element.
Remarks
Removes specified elements from the container. The order of the remaining elements is preserved. (This makes it possible to erase individual elements while iterating through the container.)
Removes the elements in the range [first, last), which must be a valid range in *this.
References and iterators to the erased elements are invalidated. Other iterators and references are not invalidated.
The iterator pos must be valid and dereferenceable. Thus the xtd::collections::generic::dictionary::end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos.

◆ erase() [3/3]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 >::erase ( const key_t &  key)
inline

Erases elements.

Parameters
keyThe key value of the elements to remove.
Returns
The number of elements removed (0 or 1).
Remarks
Removes specified elements from the container. The order of the remaining elements is preserved. (This makes it possible to erase individual elements while iterating through the container.)
Removes the element (if one exists) with the key equivalent to key.
References and iterators to the erased elements are invalidated. Other iterators and references are not invalidated.
The iterator pos must be valid and dereferenceable. Thus the xtd::collections::generic::dictionary::end() iterator (which is valid, but is not dereferenceable) cannot be used as a value for pos.

◆ extract() [1/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
node_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::extract ( const_iterator  position)
inlinenoexcept

Extracts nodes from the container.

Parameters
positionA valid iterator into this container.
Returns
A node handle that owns the extracted element, or empty node handle in case the element is not found in.
Remarks
Unlinks the node that contains the element pointed to by position and returns a node handle that owns it.
In either case, no elements are copied or moved, only the internal pointers of the container nodes are repointed.
Extracting a node invalidates only the iterators to the extracted element, and preserves the relative order of the elements that are not erased. Pointers and references to the extracted element remain valid, but cannot be used while element is owned by a node handle: they become usable if the element is inserted into a container.

◆ extract() [2/2]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
node_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::extract ( const key_t  k)
inline

Extracts nodes from the container.

Parameters
kA key to identify the node to be extracted.
Returns
A node handle that owns the extracted element, or empty node handle in case the element is not found in.
Remarks
If the container has an element with key equivalent to k, unlinks the node that contains that element from the container and returns a node handle that owns it. Otherwise, returns an empty node handle.
In either case, no elements are copied or moved, only the internal pointers of the container nodes are repointed.
Extracting a node invalidates only the iterators to the extracted element, and preserves the relative order of the elements that are not erased. Pointers and references to the extracted element remain valid, but cannot be used while element is owned by a node handle: they become usable if the element is inserted into a container.

◆ find() [1/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 >::find ( const key_t &  key) const
inline

Finds element with specific key.

Parameters
keyThe key value of the element to search for.
Returns
An iterator to the requested element. If no such element is found, past-the-end (see xtd::collections::generic::dictionary::end) iterator is returned.
Remarks
Finds an element with key equivalent to key.

◆ find() [2/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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 >::find ( const key_t &  key)
inline

Finds element with specific key.

Parameters
keyThe key value of the element to search for.
Returns
An iterator to the requested element. If no such element is found, past-the-end (see xtd::collections::generic::dictionary::end) iterator is returned.
Remarks
Finds an element with key equivalent to key.

◆ find() [3/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class find_key_t >
const_iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::find ( const find_key_t &  x) const
inline

Finds element with specific key.

Parameters
xA value of any type that can be transparently compared with a key.
Returns
An iterator to the requested element. If no such element is found, past-the-end (see xtd::collections::generic::dictionary::end) iterator is returned.
Remarks
Finds an element with key that compares equivalent to the value x. This overload participates in overload resolution only if hasher_t::is_transparent and equator_t::is_transparent are valid and each denotes a type. This assumes that such hasher_t is callable with both find_key_t and key_t type, and that the equator_t is transparent, which, together, allows calling this function without constructing an instance of key_t.

◆ find() [4/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class find_key_t >
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::find ( const find_key_t &  x)
inline

Finds element with specific key.

Parameters
xA value of any type that can be transparently compared with a key.
Remarks
Finds an element with key that compares equivalent to the value x. This overload participates in overload resolution only if hasher_t::is_transparent and equator_t::is_transparent are valid and each denotes a type. This assumes that such hasher_t is callable with both find_key_t and key_t type, and that the equator_t is transparent, which, together, allows calling this function without constructing an instance of key_t.

◆ get_allocator()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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

Returns an enumerator that iterates through the xtd::collections::generic::dictionary <key_t, value_t>.

Returns
A xtd::collections::enumerator structure for the xtd::collections::generic::dictionary <key_t, value_t>.

Implements xtd::collections::generic::ienumerable< type_t >.

◆ hash_function()

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

Returns function used to hash the keys.

Returns
The hash function.
Remarks
Returns the function that hashes the keys.

◆ insert() [1/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
key_value_pair< iterator, bool > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( const value_type value)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
valueThe element value to insert.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.
Remarks
Inserts value.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [2/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
key_value_pair< iterator, bool > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( value_type &&  value)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
valueThe element value to insert.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.
Remarks
Inserts value.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [3/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class type_t >
key_value_pair< iterator, bool > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( type_t &&  value)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
valueThe element value to insert.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.
Remarks
Inserts value.
Is equivalent to emplace(std::forward<P>(value)) and only participates in overload resolution if std::is_constructible<value_type, P&&>::value == true.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [4/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( const_iterator  hint,
const value_type value 
)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
hintThe iterator, used as a suggestion as to where to insert the content.
valueThe element value to insert.
Returns
An iterator to the inserted element, or to the element that prevented the insertion.
Remarks
Inserts value, using hint as a non-binding suggestion to where the search should start.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [5/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( const_iterator  hint,
value_type &&  value 
)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
hintThe iterator, used as a suggestion as to where to insert the content.
valueThe element value to insert.
Returns
An iterator to the inserted element, or to the element that prevented the insertion.
Remarks
Inserts value, using hint as a non-binding suggestion to where the search should start.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [6/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class type_t >
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( const_iterator  hint,
type_t &&  value 
)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
hintThe iterator, used as a suggestion as to where to insert the content.
valueThe element value to insert.
Returns
An iterator to the inserted element, or to the element that prevented the insertion.
Remarks
Inserts value, using hint as a non-binding suggestion to where the search should start.
Is equivalent to emplace_hint(hint, std::forward<P>(value)) and only participates in overload resolution if std::is_constructible<value_type, P&&>::value == true.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [7/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class input_iterator_t >
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( input_iterator_t  first,
input_iterator_t  last 
)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
firstThe first iterator of the range of elements to insert.
lastThe last iterator of the range of elements to insert.
Remarks
Inserts elements from range [first, last). If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844).
If [first, last) is not a valid range, or first and/or last are iterators into *this, the behavior is undefined.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [8/11]

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

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
ilistThe initializer list to insert the values from.
Remarks
Inserts elements from initializer list ilist. If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844).
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [9/11]

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

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
ilistThe initializer list to insert the values from.
Remarks
Inserts elements from initializer list ilist. If multiple elements in the range have keys that compare equivalent, it is unspecified which element is inserted (pending LWG2844).
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [10/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
insert_return_type xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( node_type &&  nh)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
nhA compatible node handle.
Returns
An object of xtd::collections::generic::dictionary::insert_return_type with the members initialized as follows:
  • If nh is empty, inserted is false, position is xtd::collections::generic::dictionary::end, and node is empty.
  • Otherwise if the insertion took place, inserted is true, position points to the inserted element, and node is empty.
  • If the insertion failed, inserted is false, node has the previous value of nh, and position points to an element with a key equivalent to nh.key().
Remarks
If nh is an empty node handle, does nothing. Otherwise, inserts the element owned by nh into the container , if the container doesn't already contain an element with a key equivalent to nh.key(). The behavior is undefined if nh is not empty and get_allocator() != nh.get_allocator().
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.

◆ insert() [11/11]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert ( const_iterator  hint,
node_type &&  nh 
)
inline

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Parameters
hintThe iterator, used as a suggestion as to where to insert the content.
nhA compatible node handle.
Returns
End iterator if nh was empty, iterator pointing to the inserted element if insertion took place, and iterator pointing to an element with a key equivalent to nh.key() if it failed.
Remarks
If nh is an empty node handle, does nothing and returns the end iterator. Otherwise, inserts the element owned by nh into the container, if the container doesn't already contain an element with a key equivalent to nh.key(), and returns the iterator pointing to the element with key equivalent to nh.key()(regardless of whether the insert succeeded or failed). If the insertion succeeds, nh is moved from, otherwise it retains ownership of the element. hint is used as a non-binding suggestion to where the search should start. The behavior is undefined if nh is not empty and get_allocator() != nh.get_allocator().
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated. If the insertion is successful, pointers and references to the element obtained while it is held in the node handle are invalidated, and pointers and references obtained to that element before it was extracted become valid.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ insert_or_assign() [1/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class type_t >
key_value_pair< iterator, bool > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert_or_assign ( const key_t &  k,
type_t &&  obj 
)
inline

Inserts an element or assigns to the current element if the key already exists.

Parameters
kThe key used both to look up and to insert if not found.
objThe value to insert or assign.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.
Remarks
If a key equivalent to k already exists in the container, assigns std::forward<type_t>(obj) to the xtd::collections::generic::dictionary::mapped_type corresponding to the key k. If the key does not exist, inserts the new value as if by xtd::collections::generic::dictionary::insert, constructing it from value_type(k, std::forward<type_t>(obj)).
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ insert_or_assign() [2/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class type_t >
key_value_pair< iterator, bool > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert_or_assign ( key_t &&  k,
type_t &&  obj 
)
inline

Inserts an element or assigns to the current element if the key already exists.

Parameters
kThe key used both to look up and to insert if not found.
objThe value to insert or assign.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.
Remarks
If a key equivalent to k already exists in the container, assigns std::forward<type_t>(obj) to the xtd::collections::generic::dictionary::mapped_type corresponding to the key k. If the key does not exist, inserts the new value as if by xtd::collections::generic::dictionary::insert, constructing it from value_type(k, std::forward<type_t>(obj)).
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ insert_or_assign() [3/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class type_t >
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert_or_assign ( const_iterator  hint,
const key_t &  k,
type_t &&  obj 
)
inline

Inserts an element or assigns to the current element if the key already exists.

Parameters
hintThe iterator to the position before which the new element will be inserted.
kThe key used both to look up and to insert if not found.
objThe value to insert or assign.
Returns
An iterator to the inserted element, or to the element that prevented the insertion.
Remarks
If a key equivalent to k already exists in the container, assigns std::forward<type_t>(obj) to the xtd::collections::generic::dictionary::mapped_type corresponding to the key k. If the key does not exist, inserts the new value as if by xtd::collections::generic::dictionary::insert, constructing it from value_type(k, std::forward<type_t>(obj)).
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ insert_or_assign() [4/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class type_t >
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::insert_or_assign ( const_iterator  hint,
key_t &&  k,
type_t &&  obj 
)
inline

Inserts an element or assigns to the current element if the key already exists.

Parameters
hintThe iterator to the position before which the new element will be inserted.
kThe key used both to look up and to insert if not found.
objThe value to insert or assign.
Returns
An iterator to the inserted element, or to the element that prevented the insertion.
Remarks
If a key equivalent to k already exists in the container, assigns std::forward<type_t>(obj) to the xtd::collections::generic::dictionary::mapped_type corresponding to the key k. If the key does not exist, inserts the new value as if by xtd::collections::generic::dictionary::insert, constructing it from value_type(k, std::forward<type_t>(obj)).
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ key_eq()

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

Returns the function used to compare keys for equality.

Returns
The key comparison function.
Remarks
Returns the function that compares keys for equality.

◆ merge() [1/6]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class source_hasher_t , class source_equator_t >
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::merge ( dictionary< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &  source)
inline

Splices nodes from another container.

Parameters
sourceA compatible container to transfer the nodes from.
Remarks
Attempts to extract ("splice") each element in source and insert it into *this using the hash function and key equality predicate of *this. If there is an element in *this with key equivalent to the key of an element from source, then that element is not extracted from source. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this, not into source. Iterators referring to the transferred elements and all iterators referring to *this are invalidated. Iterators to elements remaining in source remain valid.
The behavior is undefined if get_allocator() != source.get_allocator().

◆ merge() [2/6]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class source_hasher_t , class source_equator_t >
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::merge ( dictionary< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&  source)
inline

Splices nodes from another container.

Parameters
sourceA compatible container to transfer the nodes from.
Remarks
Attempts to extract ("splice") each element in source and insert it into *this using the hash function and key equality predicate of *this. If there is an element in *this with key equivalent to the key of an element from source, then that element is not extracted from source. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this, not into source. Iterators referring to the transferred elements and all iterators referring to *this are invalidated. Iterators to elements remaining in source remain valid.
The behavior is undefined if get_allocator() != source.get_allocator().

◆ merge() [3/6]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class source_hasher_t , class source_equator_t >
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::merge ( std::unordered_map< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &  source)
inline

Splices nodes from another container.

Parameters
sourceA compatible container to transfer the nodes from.
Remarks
Attempts to extract ("splice") each element in source and insert it into *this using the hash function and key equality predicate of *this. If there is an element in *this with key equivalent to the key of an element from source, then that element is not extracted from source. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this, not into source. Iterators referring to the transferred elements and all iterators referring to *this are invalidated. Iterators to elements remaining in source remain valid.
The behavior is undefined if get_allocator() != source.get_allocator().

◆ merge() [4/6]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class source_hasher_t , class source_equator_t >
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::merge ( std::unordered_map< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&  source)
inline

Splices nodes from another container.

Parameters
sourceA compatible container to transfer the nodes from.
Remarks
Attempts to extract ("splice") each element in source and insert it into *this using the hash function and key equality predicate of *this. If there is an element in *this with key equivalent to the key of an element from source, then that element is not extracted from source. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this, not into source. Iterators referring to the transferred elements and all iterators referring to *this are invalidated. Iterators to elements remaining in source remain valid.
The behavior is undefined if get_allocator() != source.get_allocator().

◆ merge() [5/6]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class source_hasher_t , class source_equator_t >
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::merge ( std::unordered_multimap< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &  source)
inline

Splices nodes from another container.

Parameters
sourceA compatible container to transfer the nodes from.
Remarks
Attempts to extract ("splice") each element in source and insert it into *this using the hash function and key equality predicate of *this. If there is an element in *this with key equivalent to the key of an element from source, then that element is not extracted from source. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this, not into source. Iterators referring to the transferred elements and all iterators referring to *this are invalidated. Iterators to elements remaining in source remain valid.
The behavior is undefined if get_allocator() != source.get_allocator().

◆ merge() [6/6]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class source_hasher_t , class source_equator_t >
void xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::merge ( std::unordered_multimap< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&  source)
inline

Splices nodes from another container.

Parameters
sourceA compatible container to transfer the nodes from.
Remarks
Attempts to extract ("splice") each element in source and insert it into *this using the hash function and key equality predicate of *this. If there is an element in *this with key equivalent to the key of an element from source, then that element is not extracted from source. No elements are copied or moved, only the internal pointers of the container nodes are repointed. All pointers and references to the transferred elements remain valid, but now refer into *this, not into source. Iterators referring to the transferred elements and all iterators referring to *this are invalidated. Iterators to elements remaining in source remain valid.
The behavior is undefined if get_allocator() != source.get_allocator().

◆ rehash()

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

Reserves at least the specified number of buckets and regenerates the hash table.

Parameters
countThe lower bound for the new number of buckets.
Remarks
Changes the number of buckets to a value n that is not less than count and satisfies n >= size() / max_load_factor(), then rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed.
Note
rehash(0) may be used to force an unconditional rehash, such as after suspension of automatic rehashing by temporarily increasing max_load_factor().

◆ remove() [1/3]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
bool xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::remove ( const key_t &  key)
inlineoverridevirtualnoexcept

Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t, value_t>.

Parameters
keyThe key of the element to remove.
Returns
true if the element is successfully found and removed; otherwise, false. This method returns false if key is not found in the xtd::collections::generic::dictionary <key_t, value_t>.
Remarks
If the xtd::collections::generic::dictionary <key_t, value_t> does not contain an element with the specified key, the xtd::collections::generic::dictionary <key_t, value_t> remains unchanged. No exception is thrown.

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

◆ remove() [2/3]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
bool xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::remove ( const value_type item)
inlineoverridenoexcept

Removes the first occurrence of a specific object from the xtd::collections::generic::dictionary <key_t, value_t>.

Parameters
itemThe object to remove from the xtd::collections::generic::dictionary <key_t, value_t>.
Returns
true if item is successfully removed; otherwise, false. This method also returns false if item value was not found in the xtd::collections::generic::dictionary <key_t, value_t>.

◆ remove() [3/3]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
bool xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::remove ( const key_t &  key,
value_t &  value 
)
inlinenoexcept

Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t, value_t>, and copies the element to the value parameter.

Parameters
keyThe key of the element to remove.
valueThe removed element.

◆ reserve()

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

Reserves space for at least the specified number of elements and regenerates the hash table.

Parameters
countThe new capacity of the container.
Remarks
Sets the number of buckets to the number needed to accommodate at least count elements without exceeding maximum load factor and rehashes the container, i.e. puts the elements into appropriate buckets considering that total number of buckets has changed. Effectively calls rehash(std::ceil(count / max_load_factor())).

◆ swap()

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

Swaps the contents.

Parameters
Thecontainer to exchange the contents with.
Remarks
Exchanges the contents of the container with those of other. Does not invoke any move, copy, or swap operations on individual elements.
All iterators and references remain valid. The xtd::collections::generic::dictionary::end iterator is invalidated. The hasher_t and equator_t objects must be Swappable, and they are exchanged using unqualified calls to non-member swap.

◆ to_string()

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

Gets a string that represents the current object.

Returns
A string that represents the current object.

Reimplemented from xtd::object.

◆ trim_excess() [1/2]

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

Sets the capacity of this dictionary to hold up a specified number of entries without any further expansion of its backing storage.

Parameters
capacityThe new capacity.
Exceptions
xtd::argument_out_of_range_exception`capacity` is less than xtd::collections::generic::dictionary::count.
Remarks
This method can be used to minimize the memory overhead once it is known that no new elements will be added.

◆ trim_excess() [2/2]

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

Sets the capacity of this dictionary to what it would be if it had been originally initialized with all its entries.

Remarks
This method can be used to minimize memory overhead once it is known that no new elements will be added to the dictionary. To allocate a minimum size storage array, execute the following statements:
void trim_excess(size_type capacity)
Sets the capacity of this dictionary to hold up a specified number of entries without any further exp...
Definition dictionary.hpp:1380
void clear() noexcept override
Removes all keys and values from the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:788

◆ try_add()

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
bool xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::try_add ( const key_t &  key,
const value_t  value 
)
inlinenoexcept

Attempts to add the specified key and value to the dictionary.

Parameters
keyThe key of the element to add.
valueThe value of the element to add.
Returns
true if the key/value pair was added to the dictionary successfully; otherwise, false.
Remarks
Unlike the xtd::collections::generic::dictionary::add method, this method doesn't throw an exception if the element with the given key exists in the dictionary. Unlike the xtd::collections::generic::dictionary indexer (operator []), xtd::collections::generic::dictionary::try_add doesn't override the element if the element with the given key exists in the dictionary. If the key already exists, xtd::collections::generic::dictionary::try_add does nothing and returns false.

◆ try_emplace() [1/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class ... args_t>
key_value_pair< iterator, bool > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::try_emplace ( const key_t &  k,
args_t &&...  args 
)
inline

Inserts in-place if the key does not exist, does nothing if the key exists.

Parameters
kThe key used both to look up and to insert if not found.
argsThe arguments to forward to the constructor of the element.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.
Remarks
If value_type is not EmplaceConstructible into unordered_map from the corresponding expression, the behavior is undefined.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ try_emplace() [2/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class ... args_t>
key_value_pair< iterator, bool > xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::try_emplace ( key_t &&  k,
args_t &&...  args 
)
inline

Inserts in-place if the key does not exist, does nothing if the key exists.

Parameters
kThe key used both to look up and to insert if not found.
argsThe arguments to forward to the constructor of the element.
Returns
A pair consisting of an iterator to the inserted element (or to the element that prevented the insertion) and a bool value set to true if and only if the insertion took place.
Remarks
If value_type is not EmplaceConstructible into unordered_map from the corresponding expression, the behavior is undefined.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ try_emplace() [3/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class ... args_t>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::try_emplace ( const_iterator  hint,
const key_t &  k,
args_t &&...  args 
)
inline

Inserts in-place if the key does not exist, does nothing if the key exists.

Parameters
hintThe iterator to the position before which the new element will be inserted.
kThe key used both to look up and to insert if not found.
argsThe arguments to forward to the constructor of the element.
Returns
An iterator to the inserted element, or to the element that prevented the insertion.
Remarks
If value_type is not EmplaceConstructible into unordered_map from the corresponding expression, the behavior is undefined.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ try_emplace() [4/4]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class ... args_t>
iterator xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >::try_emplace ( const_iterator  hint,
key_t &&  k,
args_t &&...  args 
)
inline

Inserts in-place if the key does not exist, does nothing if the key exists.

Parameters
hintThe iterator to the position before which the new element will be inserted.
kThe key used both to look up and to insert if not found.
argsThe arguments to forward to the constructor of the element.
Returns
An iterator to the inserted element, or to the element that prevented the insertion.
Remarks
If value_type is not EmplaceConstructible into unordered_map from the corresponding expression, the behavior is undefined.
If after the operation the new number of elements is greater than old xtd::collections::generic::dictionary::max_load_factor * xtd::collections::generic::dictionary::bucket_count a rehashing takes place.
If rehashing occurs (due to the insertion), all iterators are invalidated. Otherwise (no rehashing), iterators are not invalidated.

◆ try_get_value()

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

Gets the value associated with the specified key.

Parameters
keyThe key of the value to get.
valueWhen this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter.
Returns
true if the xtd::collections::generic::dictionary <key_t, value_t> contains an element with the specified key; otherwise, false.

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

◆ operator=() [1/6]

template<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = helpers::allocator<std::pair<const key_t, value_t>>>
template<class init_key_t , class 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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<class key_t , class value_t , class hasher_t = helpers::hasher<key_t>, class equator_t = helpers::equator<key_t>, class allocator_t = 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: