15#include <unordered_map>
66 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 >>>
91 if (comparer)
return comparer->get_hash_code(key);
92 return hasher_t {}(key);
125 if (&
a == &
b)
return true;
126 if (comparer)
return comparer->equals(
a,
b);
127 return equator_t {}(
a,
b);
135 const iequality_comparer < key_t > *
comparer =
nullptr;
159 using base_type = std::unordered_map < key_type, mapped_type, hasher, key_equal, allocator_type >;
165 using pointer =
typename std::allocator_traits < allocator_t >::pointer;
167 using const_pointer =
typename std::allocator_traits < allocator_t >::const_pointer;
241 for (
const auto& item : collection)
250 template <
class equality_comparer_t >
276 dictionary(size_type bucket_count, const allocator_type& alloc) noexcept : data_(xtd::new_ptr<data>(bucket_count)) {}
301 template <
class equality_comparer_t >
312 template <
class equality_comparer_t >
314 for (
const auto& item : collection)
328 template <
class equality_comparer_t >
337 explicit dictionary(const allocator_t& alloc) noexcept {}
350 template <
class input_iterator_t >
353 const auto& [key, value] = *
iterator;
365 template <
class input_iterator_t >
368 const auto& [key, value] = *
iterator;
381 template <
class input_iterator_t >
384 const auto& [key, value] = *
iterator;
404 dictionary(const dictionary& other, const allocator_type& alloc) noexcept : data_(xtd::new_ptr<data>(other.data_->comparer, other.data_->items, other.data_->version)) {}
416 const auto& [key, value] = *
iterator;
430 const auto& [key, value] = *
iterator;
463 for (
const auto& [key, value] : init) {
465 (*this)[key] = value;
479 for (
const auto& [key, value] : init) {
481 (*this)[key] = value;
496 for (
const auto& [key, value] : init) {
498 (*this)[key] = value;
513 template <
class init_key_t,
class init_value_t >
515 for (
const auto& [key, value] : init) {
517 (*this)[key] = value;
530 template <
class init_key_t,
class init_value_t >
532 for (
const auto& [key, value] : init) {
534 (*this)[key] = value;
548 template <
class init_key_t,
class init_value_t >
550 for (
const auto& [key, value] : init) {
552 (*this)[key] = value;
588 const iequality_comparer < key_t > &
comparer() const noexcept {
589 if (data_->comparer)
return *data_->comparer;
588 const iequality_comparer < key_t > &
comparer() const noexcept {
…}
602 bool empty() const noexcept {
return data_->items.empty();}
646 for (
const auto& [key, value] : data_->items)
707 for (
const auto& [key, value] : data_->items)
722 void add(
const key_t & key,
const value_t value)
override {
722 void add(
const key_t & key,
const value_t value)
override {
…}
730 add(item.key(), item.value());
739 const value_t&
at(
const key_t & key)
const {
740 auto iterator = data_->items.find(key);
739 const value_t&
at(
const key_t & key)
const {
…}
750 value_t&
at(
const key_t & key) {
751 auto iterator = data_->items.find(key);
750 value_t&
at(
const key_t & key) {
…}
761 return data_->items.begin(
n);
769 return data_->items.begin(
n);
787 return data_->items.begin(
n);
795 return data_->items.end(
n);
801 data_->items.clear();
808 return data_->items.find(key) != data_->items.end();
813 template <
class contains_key_t >
815 return data_->items.find(
x) != data_->items.end();
824 return iterator->value() == item.value();
835 bool contains_value(
const value_t& value)
const noexcept {
836 for (
const auto& [item_key, item_value] : *
this)
837 if (item_value == value)
return true;
848 for (
const auto& item : *
this)
849 array[array_index + index++] = item;
860 template <
class ...args_t >
861 key_value_pair < iterator, bool >
emplace(args_t&& ...args) {
862 const auto& [
iterator, succeeded] = data_->items.emplace(std::forward < args_t > (args)...);
863 if (succeeded) ++data_->version;
864 return {to_type_iterator(
iterator), succeeded};
861 key_value_pair < iterator, bool >
emplace(args_t&& ...args) {
…}
875 template <
class ...args_t >
878 return to_type_iterator(data_->items.emplace_hint(to_base_type_iterator(hint), std::forward < args_t > (args)...));
886 return data_->items.end(
n);
894 return data_->items.end(
n);
909 key_value_pair < iterator, iterator >
equal_range(
const key_t & key) {
910 const auto& [
first,
last] = data_->items.equal_range(key);
911 return {to_type_iterator(
first), to_type_iterator(
last)};
909 key_value_pair < iterator, iterator >
equal_range(
const key_t & key) {
…}
918 template <
class equal_range_key_t >
919 key_value_pair < const_iterator, const_iterator >
equal_range(
const equal_range_key_t& key)
const {
920 const auto& [
first,
last] = data_->items.equal_range(key);
921 return {to_const_type_iterator(
first), to_const_type_iterator(
last)};
919 key_value_pair < const_iterator, const_iterator >
equal_range(
const equal_range_key_t& key)
const {
…}
928 template <
class equal_range_key_t >
929 key_value_pair < iterator, iterator >
equal_range(
const equal_range_key_t&
x) {
930 const auto& [
first,
last] = data_->items.equal_range(
x);
931 return {to_type_iterator(
first), to_type_iterator(
last)};
929 key_value_pair < iterator, iterator >
equal_range(
const equal_range_key_t&
x) {
…}
938 key_value_pair < const_iterator, const_iterator >
equal_range(
const key_t &
x)
const {
939 const auto& [
first,
last] = data_->items.equal_range(
x);
940 return {to_const_type_iterator(
first), to_const_type_iterator(
last)};
938 key_value_pair < const_iterator, const_iterator >
equal_range(
const key_t &
x)
const {
…}
952 return to_type_iterator(data_->items.erase(to_const_base_type_iterator(pos)));
964 return to_type_iterator(data_->items.erase(to_const_base_type_iterator(
first), to_const_base_type_iterator(
last)));
974 auto removed_count = data_->items.erase(key);
975 if (removed_count) ++data_->version;
976 return removed_count;
987 return data_->items.extract(to_const_base_type_iterator(position));
997 return data_->items.extract(
k);
1005 return to_const_type_iterator(data_->items.find(key));
1013 return to_type_iterator(data_->items.find(key));
1020 template <
class find_key_t >
1022 return to_const_type_iterator(data_->items.find(
x));
1028 template <
class find_key_t >
1030 return to_type_iterator(data_->items.find(
x));
1040 struct internal_enumerator :
public ienumerator < value_type > {
1044 const value_type & current()
const override {
1046 if (iterator_ != items_.items().cend()) {
1047 static thread_local auto value =
value_type {};
1051 static auto default_value_type =
value_type {};
1052 return default_value_type;
1055 bool move_next()
override {
1057 if (!reset_)
return ++iterator_ != items_.items().cend();
1059 iterator_ = items_.items().cbegin();
1060 return iterator_ != items_.items().cend();
1063 void reset()
override {
1065 version_ = items_.data_->version;
1066 iterator_ = items_.items().cend();
1072 typename dictionary::base_type::const_iterator iterator_ = items_.
items().cend();
1082 return data_->items.hash_function();
1092 const auto& [
iterator, succeeded] = data_->items.insert(value);
1093 if (succeeded) ++data_->version;
1094 return {to_type_iterator(
iterator), succeeded};
1103 const auto& [
iterator, succeeded] = data_->items.insert(value);
1104 if (succeeded) ++data_->version;
1105 return {to_type_iterator(
iterator), succeeded};
1114 template <
class type_t >
1115 key_value_pair < iterator, bool >
insert(type_t&& value) {
1116 const auto& [
iterator, succeeded] = data_->items.insert(value);
1117 if (succeeded) ++data_->version;
1118 return {to_type_iterator(
iterator), succeeded};
1115 key_value_pair < iterator, bool >
insert(type_t&& value) {
…}
1129 return to_type_iterator(data_->items.insert(to_const_base_type_iterator(hint), value));
1140 return to_type_iterator(data_->items.insert(to_const_base_type_iterator(hint), value));
1150 template <
class type_t >
1153 return to_type_iterator(data_->items.insert(to_const_base_type_iterator(hint), value));
1162 template <
class input_iterator_t >
1165 const auto& [key, value] = *
iterator;
1174 void insert(std::initializer_list < base_value_type > ilist) {
1175 for (
const auto& [key, value] : ilist)
1176 add(std::forward < value_type > ({key, value}));
1174 void insert(std::initializer_list < base_value_type > ilist) {
…}
1183 template <
class init_key_t,
class init_value_t >
1184 void insert(std::initializer_list < key_value_pair < init_key_t, init_value_t>> ilist) {
1185 for (
const auto& [key, value] : ilist)
1186 add(std::forward < value_type > ({key, value}));
1184 void insert(std::initializer_list < key_value_pair < init_key_t, init_value_t>> ilist) {
…}
1199 return data_->items.inser(nh);
1211 return to_type_iterator(data_->items.inser(to_const_base_type_iterator(hint), nh));
1221 template <
class type_t >
1223 const auto& [
iterator, succeeded] = data_->items.insert_or_assign(
k, obj);
1224 if (succeeded) ++data_->version;
1225 return {to_type_iterator(
iterator), succeeded};
1234 template <
class type_t >
1236 const auto& [
iterator, succeeded] = data_->items.insert_or_assign(std::move(
k), obj);
1237 if (succeeded) ++data_->version;
1238 return {to_type_iterator(
iterator), succeeded};
1248 template <
class type_t >
1251 return to_type_iterator(data_->items.insert_or_assign(to_const_base_type_iterator(hint),
k, obj));
1261 template <
class type_t >
1264 return to_type_iterator(data_->items.insert_or_assign(to_const_base_type_iterator(hint), std::move(
k), obj));
1271 return data_->items.key_eq();
1278 template <
class source_hasher_t,
class source_equator_t >
1280 data_->items.merge(source.
items);
1288 template <
class source_hasher_t,
class source_equator_t >
1290 data_->items.merge(std::move(source.items));
1298 template <
class source_hasher_t,
class source_equator_t >
1299 void merge(std::unordered_map < key_t, value_t, source_hasher_t, source_equator_t, allocator_t > & source) {
1300 data_->items.merge(source);
1299 void merge(std::unordered_map < key_t, value_t, source_hasher_t, source_equator_t, allocator_t > & source) {
…}
1308 template <
class source_hasher_t,
class source_equator_t >
1309 void merge(std::unordered_map < key_t, value_t, source_hasher_t, source_equator_t, allocator_t > && source) {
1310 data_->items.merge(std::move(source));
1309 void merge(std::unordered_map < key_t, value_t, source_hasher_t, source_equator_t, allocator_t > && source) {
…}
1318 template <
class source_hasher_t,
class source_equator_t >
1319 void merge(std::unordered_multimap < key_t, value_t, source_hasher_t, source_equator_t, allocator_t > & source) {
1320 data_->items.merge(source);
1319 void merge(std::unordered_multimap < key_t, value_t, source_hasher_t, source_equator_t, allocator_t > & source) {
…}
1328 template <
class source_hasher_t,
class source_equator_t >
1329 void merge(std::unordered_multimap < key_t, value_t, source_hasher_t, source_equator_t, allocator_t > && source) {
1330 data_->items.merge(std::move(source));
1329 void merge(std::unordered_multimap < key_t, value_t, source_hasher_t, source_equator_t, allocator_t > && source) {
…}
1339 data_->items.rehash(
count);
1346 bool remove(
const key_t & key)
noexcept override {
1347 return erase(key) == 1;
1346 bool remove(
const key_t & key)
noexcept override {
…}
1354 if (!contains_value(item.value()))
return false;
1355 return erase(item.key()) == 1;
1361 bool remove(
const key_t & key, value_t& value)
noexcept {
1361 bool remove(
const key_t & key, value_t& value)
noexcept {
…}
1372 data_->items.reserve(
count);
1380 data_->items.swap(
other.data_->items);
1381 std::swap(data_->version,
other.data_->version);
1386 xtd::string to_string() const noexcept
override {
return xtd::string::format(
"{{{}}}", xtd::string::join(
", ", *
this));}
1412 bool try_add(
const key_t & key,
const value_t value)
noexcept {
1413 const auto& [
iterator, succeeded] = data_->items.insert(std::forward < base_value_type > ({key, value}));
1414 if (succeeded) ++data_->version;
1412 bool try_add(
const key_t & key,
const value_t value)
noexcept {
…}
1425 template <
class ...args_t >
1426 key_value_pair < iterator, bool >
try_emplace(
const key_t &
k, args_t&&... args) {
1427 const auto& [
iterator, succeeded] = to_type_iterator(data_->items.try_emplace(
k, std::forward < args_t > (args)...));
1428 if (succeeded) ++data_->version;
1429 return {to_type_iterator(
iterator), succeeded};
1426 key_value_pair < iterator, bool >
try_emplace(
const key_t &
k, args_t&&... args) {
…}
1438 template <
class ...args_t >
1439 key_value_pair < iterator, bool >
try_emplace(key_t&&
k, args_t&&... args) {
1440 const auto& [
iterator, succeeded] = to_type_iterator(data_->items.try_emplace(std::move(
k), std::forward < args_t > (args)...));
1441 if (succeeded) ++data_->version;
1442 return {to_type_iterator(
iterator), succeeded};
1452 template <
class ...args_t >
1455 return to_type_iterator(data_->items.try_emplace(to_const_base_type_iterator(hint),
k, std::forward < args_t > (args)...));
1465 template <
class ...args_t >
1468 return to_type_iterator(data_->items.try_emplace(to_const_base_type_iterator(hint), std::move(
k), std::forward < args_t > (args)...));
1493 data_->comparer = std::move(
other.data_->comparer);
1494 data_->items = std::move(
other.data_->items);
1495 data_->version = std::move(
other.data_->version);
1502 data_->items = std::move(
other);
1514 data_->items.clear();
1515 for (
const auto& [key, value] :
other)
1522 data_->
items.clear();
1523 for (
const auto& [key, value] : ilist)
1529 template <
class init_key_t,
class init_value_t >
1531 data_->
items.clear();
1532 for (
const auto& [key, value] : ilist)
1552 return data_->items[key];}
1556 operator const base_type & ()
const noexcept {
return data_->items;}
1563 typename base_type::const_iterator to_const_base_type_iterator(
const_iterator value)
const noexcept {
1564 return idictionary < key_t, value_t >::to_const_iterator(value, *
this, data_->items);
1567 const_iterator to_const_type_iterator(
typename base_type::const_iterator value)
const noexcept {
1568 return idictionary < key_t, value_t >::to_const_iterator(value, data_->items, *
this);
1571 typename base_type::const_iterator to_base_type_iterator(
const_iterator value)
const noexcept {
1572 return idictionary < key_t, value_t >::to_iterator(value, *
this, data_->items);
1575 typename base_type::iterator to_base_type_iterator(
iterator value)
noexcept {
1576 return idictionary < key_t, value_t >::to_iterator(value, *
this, data_->items);
1579 const_iterator to_type_iterator(
typename base_type::const_iterator value)
const noexcept {
1580 return idictionary < key_t, value_t >::to_iterator(value, data_->items, *
this);
1583 iterator to_type_iterator(
typename base_type::iterator value)
noexcept {
1584 return idictionary < key_t, value_t >::to_iterator(value, data_->items, *
this);
1589 data(
ptr < iequality_comparer < key_t>> comparer) : comparer {comparer}, items {
size_type {}, hasher {comparer.get()}, equator {comparer.get()},
allocator_type {}} {}
1591 data(
ptr < iequality_comparer < key_t>> comparer,
const base_type & items,
size_type version) noexcept : comparer {comparer}, items {
size_type {}, hasher {comparer.get()}, equator {comparer.get()},
allocator_type {}}, version {version} {
1592 for (
const auto& item : items)
1593 this->items.insert(item);
1596 for (
auto&& item : items)
1597 this->items.insert(item);
1603 xtd::object sync_root;
1611 template <
class key_t,
class value_t >
1614 template <
class key_t,
class value_t >
1617 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 >>>
1618 dictionary(std::initializer_list < key_value_pair < key_t, value_t>>,
xtd::size = 0, hasher_t = hasher_t {}, equator_t = equator_t {}, allocator_t = allocator_t {}) -> dictionary < key_t, value_t, hasher_t, equator_t, allocator_t >;
1620 template <
class key_t,
class value_t,
class allocator_t >
1623 template <
class key_t,
class value_t,
class allocator_t >
1626 template <
class key_t,
class value_t,
class hasher_t,
class allocator_t >
1629 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 >>>
1630 dictionary(std::initializer_list < std::pair < key_t, value_t>>,
xtd::size bucket_count = 0, hasher_t = hasher_t {}, equator_t = equator_t {}, allocator_t = allocator_t {}) -> dictionary < key_t, value_t, hasher_t, equator_t, allocator_t >;
1632 template <
class key_t,
class value_t,
class allocator_t >
1635 template <
class key_t,
class value_t,
class allocator_t >
1638 template <
class key_t,
class value_t,
class hasher_t,
class allocator_t >
1641 template <
class input_iterator_t,
class hasher_t = helpers::hasher < helpers::iterator_key_t<input_iterator_t>>,
class equator_t = helpers::equator<helpers::iterator_key_t<input_iterator_t>>,
class allocator_t = helpers::allocator < helpers::iterator_to_allocator_t < input_iterator_t >>>
1644 template <
class input_iterator_t,
class allocator_t >
1647 template <
class input_iterator_t,
class allocator_t >
1650 template <
class input_iterator_t,
class hasher_t,
class allocator_t >
Contains xtd::collections::generic::helpers::allocator alias.
Contains xtd::argument_out_of_range_exception exception.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
virtual size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(),...
Definition basic_array.hpp:246
Provides a base class for implementations of the xtd::collections::generic::icomparer <type_t> generi...
Definition comparer.hpp:33
Represents a collection of keys and values.
Definition dictionary.hpp:67
typename xtd::collections::generic::idictionary< key_t, value_t >::key_type key_type
Represents the dictionary key type.
Definition dictionary.hpp:143
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:1392
void merge(std::unordered_map< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source)
Splices nodes from another container.
Definition dictionary.hpp:1309
iterator erase(const_iterator pos)
Erases elements.
Definition dictionary.hpp:950
size_type max_size() const noexcept
Gets the maximum number of elements the container is able to hold due to system or library implementa...
Definition dictionary.hpp:669
const xtd::object & sync_root() const noexcept override
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollecti...
Definition dictionary.hpp:699
dictionary(dictionary &&other) noexcept=default
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a varie...
typename base_type::node_type node_type
Represents the dictionary node type.
Definition dictionary.hpp:177
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.
Definition dictionary.hpp:1453
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,...
Definition dictionary.hpp:1361
typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_collection value_collection
Represents the idictionary value collection type.
Definition dictionary.hpp:183
local_iterator end(size_type n)
Returns an iterator to the end of the specified bucket.
Definition dictionary.hpp:885
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 varie...
Definition dictionary.hpp:495
const value_t & operator[](const key_t &key) const override
Gets the element with the specified key.
Definition dictionary.hpp:1543
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 varie...
Definition dictionary.hpp:549
hasher hash_function() const
Returns function used to hash the keys.
Definition dictionary.hpp:1081
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 varie...
Definition dictionary.hpp:446
const_iterator find(const key_t &key) const
Finds element with specific key.
Definition dictionary.hpp:1004
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 eq...
Definition dictionary.hpp:1115
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 eq...
Definition dictionary.hpp:1138
equator key_equal
Represents the dictionary key_equal type.
Definition dictionary.hpp:153
value_type & reference
Represents the dictionary reference type.
Definition dictionary.hpp:161
insert_return_type insert(node_type &&nh)
Inserts element(s) into the container, if the container doesn't already contain an element with an eq...
Definition dictionary.hpp:1197
void add(const value_type &item) override
Adds an item to the xtd::collections::generic::icollection <type_t>.
Definition dictionary.hpp:729
node_type extract(const key_t k)
Extracts nodes from the container.
Definition dictionary.hpp:995
size_type capacity() const noexcept
Definition dictionary.hpp:575
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 eq...
Definition dictionary.hpp:1091
typename base_type::const_local_iterator const_local_iterator
Represents the const local iterator of dictionary value type.
Definition dictionary.hpp:175
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.
Definition dictionary.hpp:1439
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 varie...
Definition dictionary.hpp:414
const iequality_comparer< key_t > & comparer() const noexcept
Gets the td::collections::generic::iequality_comparer <type_t> that is used to determine equality of ...
Definition dictionary.hpp:588
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.
Definition dictionary.hpp:1262
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 c...
Definition dictionary.hpp:313
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 eq...
Definition dictionary.hpp:1174
const_local_iterator cbegin(size_type n) const
Returns an iterator to the beginning of the specified bucket.
Definition dictionary.hpp:786
value_t & at(const key_t &key)
Gets the element with the specified key.
Definition dictionary.hpp:750
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 i...
Definition dictionary.hpp:329
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 eq...
Definition dictionary.hpp:1127
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...
Definition dictionary.hpp:775
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,...
Definition dictionary.hpp:845
void reserve(size_type count)
Reserves space for at least the specified number of elements and regenerates the hash table.
Definition dictionary.hpp:1371
void swap(dictionary &other) noexcept
Swaps the contents.
Definition dictionary.hpp:1379
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 varie...
Definition dictionary.hpp:462
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 varie...
Definition dictionary.hpp:382
xtd::size ensure_capacity(xtd::size capacity) noexcept
Ensures that the dictionary can hold up to a specified number of entries without any further expansio...
Definition dictionary.hpp:900
std::unordered_map< key_type, mapped_type, hasher, key_equal, allocator_type > base_type
Represents the dictionary base type.
Definition dictionary.hpp:159
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 eq...
Definition dictionary.hpp:1102
const_iterator find(const find_key_t &x) const
Finds element with specific key.
Definition dictionary.hpp:1021
void clear() noexcept override
Removes all keys and values from the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:800
dictionary() noexcept=default
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that i...
iterator erase(const_iterator first, const_iterator last)
Erases elements.
Definition dictionary.hpp:962
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 varie...
Definition dictionary.hpp:428
bool empty() const noexcept
Checks if the container has no elements, i.e. whether begin() == end().
Definition dictionary.hpp:602
bool try_add(const key_t &key, const value_t value) noexcept
Attempts to add the specified key and value to the dictionary.
Definition dictionary.hpp:1412
const value_t & at(const key_t &key) const
Gets the element with the specified key.
Definition dictionary.hpp:739
bool remove(const value_type &item) noexcept override
Removes the first occurrence of a specific object from the xtd::collections::generic::dictionary <key...
Definition dictionary.hpp:1353
void merge(dictionary< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source)
Splices nodes from another container.
Definition dictionary.hpp:1289
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 eq...
Definition dictionary.hpp:1209
const_iterator begin() const noexcept override
Returns an iterator to the first element of the enumerable.
Definition dictionary.hpp:562
key_value_pair< const_iterator, const_iterator > equal_range(const key_t &x) const
Returns range of elements matching a specific key.
Definition dictionary.hpp:938
key_value_pair< iterator, bool > emplace(args_t &&...args)
Constructs element in-place.
Definition dictionary.hpp:861
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 varie...
Definition dictionary.hpp:451
key_equal key_eq() const
Returns the function used to compare keys for equality.
Definition dictionary.hpp:1270
iterator emplace_hint(iterator hint, args_t &&...args)
constructs elements in-place using a hint
Definition dictionary.hpp:876
iterator find(const find_key_t &x)
Finds element with specific key.
Definition dictionary.hpp:1029
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 eq...
Definition dictionary.hpp:1151
key_value_pair< iterator, iterator > equal_range(const key_t &key)
Returns range of elements matching a specific key.
Definition dictionary.hpp:909
bool remove(const key_t &key) noexcept override
Removes the value with the specified key from the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:1346
void rehash(size_type count)
Reserves at least the specified number of buckets and regenerates the hash table.
Definition dictionary.hpp:1338
const_local_iterator begin(size_type n) const
Returns an iterator to the beginning of the specified bucket.
Definition dictionary.hpp:768
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 varie...
Definition dictionary.hpp:351
typename xtd::collections::generic::idictionary< key_type, mapped_type >::iterator iterator
Represents the iterator of dictionary value type.
Definition dictionary.hpp:169
node_type extract(const_iterator position) noexcept
Extracts nodes from the container.
Definition dictionary.hpp:985
bool contains(const key_t &key) const noexcept
Checks if the container contains element with specific key.
Definition dictionary.hpp:807
void trim_excess()
Sets the capacity of this dictionary to what it would be if it had been originally initialized with a...
Definition dictionary.hpp:1403
typename base_type::insert_return_type insert_return_type
Represents the dictionary insert return type.
Definition dictionary.hpp:179
dictionary & operator=(dictionary &&other) noexcept
Move assignment operator. Replaces the contents with a copy of the contents of other.
Definition dictionary.hpp:1492
const_iterator end() const noexcept override
Returns an iterator to the element following the last element of the enumerable.
Definition dictionary.hpp:606
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 eq...
Definition dictionary.hpp:1163
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 varie...
Definition dictionary.hpp:366
key_value_pair< const_iterator, const_iterator > equal_range(const equal_range_key_t &key) const
Returns range of elements matching a specific key.
Definition dictionary.hpp:919
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 varie...
Definition dictionary.hpp:531
size_type bucket_size(size_type n) const noexcept
Returns the number of elements in the bucket with index n.
Definition dictionary.hpp:780
local_iterator begin(size_type n)
Returns an iterator to the beginning of the specified bucket.
Definition dictionary.hpp:760
iterator end() noexcept override
Returns an iterator to the element following the last element of the enumerable.
Definition dictionary.hpp:610
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:722
bool contains(const value_type &item) const noexcept override
Determines whether an element is in the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:821
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 varie...
Definition dictionary.hpp:289
key_value_pair< iterator, iterator > equal_range(const equal_range_key_t &x)
Returns range of elements matching a specific key.
Definition dictionary.hpp:929
bool is_synchronized() const noexcept override
Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is sync...
Definition dictionary.hpp:631
size_type size() const noexcept
Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:676
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.
Definition dictionary.hpp:1466
const_local_iterator end(size_type n) const
Returns an iterator to the end of the specified bucket.
Definition dictionary.hpp:893
value_collection values() const noexcept override
Gets a collection containing the values in the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:705
void merge(dictionary< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source)
Splices nodes from another container.
Definition dictionary.hpp:1279
std::pair< const key_t, value_t > base_value_type
Represents the dictionary base value type.
Definition dictionary.hpp:157
size_type erase(const key_t &key)
Erases elements.
Definition dictionary.hpp:973
dictionary(const dictionary &other) noexcept
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a varie...
Definition dictionary.hpp:394
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 eq...
Definition dictionary.hpp:1184
dictionary(dictionary &&other, const allocator_type &alloc) noexcept
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a varie...
Definition dictionary.hpp:442
const_local_iterator cend(size_type n) const
Returns an iterator to the end of the specified bucket.
Definition dictionary.hpp:794
void merge(std::unordered_map< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source)
Splices nodes from another container.
Definition dictionary.hpp:1299
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 c...
Definition dictionary.hpp:302
enumerator< value_type > get_enumerator() const noexcept override
Returns an enumerator that iterates through the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:1039
typename xtd::collections::generic::idictionary< key_type, mapped_type >::const_iterator const_iterator
Represents the const iterator of dictionary value type.
Definition dictionary.hpp:171
bool contains(const contains_key_t &x) const
Checks if the container contains element with specific key.
Definition dictionary.hpp:814
key_collection keys() const noexcept override
Gets a collection containing the keys in the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:644
const_iterator cbegin() const noexcept override
Returns an iterator to the first element of the enumerable.
Definition dictionary.hpp:579
virtual const base_type & items() const noexcept
Returns the underlying base type items.
Definition dictionary.hpp:635
void merge(std::unordered_multimap< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &source)
Splices nodes from another container.
Definition dictionary.hpp:1319
bool try_get_value(const key_t &key, value_t &value) const override
Gets the value associated with the specified key.
Definition dictionary.hpp:1475
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.
Definition dictionary.hpp:1235
dictionary(const equality_comparer_t &comparer)
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that i...
Definition dictionary.hpp:251
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 varie...
Definition dictionary.hpp:478
bool contains_key(const key_t &key) const noexcept override
Determines whether the xtd::collections::generic::dictionary <key_t, value_t> contains the specified ...
Definition dictionary.hpp:831
float load_factor() const
Gets the average number of elements per bucket, that is, xtd::collections::generic::dictionary::size ...
Definition dictionary.hpp:653
typename xtd::collections::generic::idictionary< key_type, mapped_type >::key_collection key_collection
Represents the idictionary key collection type.
Definition dictionary.hpp:181
allocator_t allocator_type
Represents the dictionary allocator type.
Definition dictionary.hpp:155
typename std::allocator_traits< allocator_t >::const_pointer const_pointer
Represents the dictionary const pointer type.
Definition dictionary.hpp:167
void merge(std::unordered_multimap< key_t, value_t, source_hasher_t, source_equator_t, allocator_t > &&source)
Splices nodes from another container.
Definition dictionary.hpp:1329
iterator begin() noexcept override
Returns an iterator to the first element of the enumerable.
Definition dictionary.hpp:565
size_type bucket_count() const noexcept
Definition dictionary.hpp:570
const_iterator cend() const noexcept override
Returns an iterator to the element following the last element of the enumerable.
Definition dictionary.hpp:583
xtd::ptrdiff difference_type
Represents the dictionary difference type.
Definition dictionary.hpp:151
typename std::allocator_traits< allocator_t >::pointer pointer
Represents the dictionary pointer type.
Definition dictionary.hpp:165
void max_load_factor(float value) const
Sets the maximum load factor (number of elements per bucket). The container automatically increases t...
Definition dictionary.hpp:664
const value_type & const_reference
Represents the dictionary const reference type.
Definition dictionary.hpp:163
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.
Definition dictionary.hpp:1222
size_type max_bucket_count() const noexcept
Gets the maximum number of buckets the container is able to hold due to system or library implementat...
Definition dictionary.hpp:657
typename base_type::local_iterator local_iterator
Represents the local iterator of dictionary value type.
Definition dictionary.hpp:173
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.
Definition dictionary.hpp:1249
typename xtd::collections::generic::idictionary< key_t, value_t >::mapped_type mapped_type
Represents the dictionary mapped type.
Definition dictionary.hpp:145
iterator find(const key_t &key)
Finds element with specific key.
Definition dictionary.hpp:1012
typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_type value_type
Represents the dictionary value type.
Definition dictionary.hpp:147
allocator_type get_allocator() const noexcept
Returns the allocator associated with the container.
Definition dictionary.hpp:1035
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 varie...
Definition dictionary.hpp:264
dictionary(const ienumerable< value_type > &collection)
Initializes a new instance of the xtd::collections::generic::dictionary <key_t, value_t> class that c...
Definition dictionary.hpp:240
xtd::string to_string() const noexcept override
Gets a string that represents the current object.
Definition dictionary.hpp:1386
virtual base_type & items() noexcept
Returns the underlying base type items.
Definition dictionary.hpp:638
bool is_read_only() const noexcept override
Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
Definition dictionary.hpp:615
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.
Definition dictionary.hpp:1426
float max_load_factor() const
Gets the maximum load factor (number of elements per bucket). The container automatically increases t...
Definition dictionary.hpp:661
xtd::size size_type
Represents the dictionary size type.
Definition dictionary.hpp:149
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 varie...
Definition dictionary.hpp:514
size_type count() const noexcept override
Gets the number of key/value pairs contained in the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:598
static const equality_comparer & default_equality_comparer()
Gets the default equality comparer for the type specified by the generic argument.
Definition equality_comparer.hpp:42
virtual const_iterator cbegin() const
Returns an iterator to the first element of the enumerable.
Definition enumerable_iterators.hpp:148
virtual const_iterator begin() const
Returns an iterator to the first element of the enumerable.
Definition enumerable_iterators.hpp:141
virtual const_iterator cend() const
Returns an iterator to the element following the last element of the enumerable.
Definition enumerable_iterators.hpp:152
virtual const_iterator end() const
Returns an iterator to the element following the last element of the enumerable.
Definition enumerable_iterators.hpp:156
Represents a generic collection of key/value pairs.
Definition idictionary.hpp:44
xtd::collections::generic::list< mapped_type > value_collection
Definition idictionary.hpp:62
xtd::collections::generic::list< key_type > key_collection
Definition idictionary.hpp:60
typename xtd::collections::generic::icollection< value_type >::const_iterator const_iterator
Definition idictionary.hpp:58
xtd::any_object key_type
Definition idictionary.hpp:50
typename xtd::collections::generic::icollection< value_type >::iterator iterator
Definition idictionary.hpp:56
xtd::any_object mapped_type
Definition idictionary.hpp:52
typename xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< xtd::any_object, xtd::any_object > >::value_type value_type
Definition idictionary.hpp:54
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:36
Supports a simple iteration over a generic collection.
Definition ienumerator.hpp:58
Defines methods to support the comparison of objects for equality.
Definition iequality_comparer.hpp:34
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:44
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.hpp:114
Contains xtd::collections::generic::helpers::equator struct.
Contains xtd::collections::generic::idictionary <key_t, value_t> interface.
Contains xtd::collections::generic::key_not_found_exception exception.
generic::enumerator< xtd::any_object > enumerator
Supports a simple iteration over a non-generic collection.
Definition enumerator.hpp:28
generic::ienumerable< xtd::any_object > ienumerable
Exposes an enumerator, which supports a simple iteration over a non-generic collection.
Definition ienumerable.hpp:32
generic::idictionary< xtd::any_object, xtd::any_object > idictionary
interface IComparer exposes a method that compares two objects.
Definition idictionary.hpp:27
std::remove_const_t< std::tuple_element_t< 0, iterator_value_t< input_iterator_t > > > iterator_key_t
Represents the key iterator type.
Definition iterator.hpp:44
std::allocator< type_t > allocator
Represent an allocator alias.
Definition allocator.hpp:38
std::tuple_element_t< 1, iterator_value_t< input_iterator_t > > iterator_mapped_t
Represents the mapped iterator type.
Definition iterator.hpp:57
@ argument
The argument is not valid.
Definition exception_case.hpp:31
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:63
@ key_not_found
The key is not found.
Definition exception_case.hpp:69
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.hpp:27
std::ptrdiff_t ptrdiff
Represent the signed integer type of the result of subtracting two pointers.
Definition ptrdiff.hpp:23
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
@ other
The operating system is other.
Definition platform_id.hpp:58
@ a
The A key.
Definition console_key.hpp:88
@ add
The Add key.
Definition console_key.hpp:170
@ n
The N key.
Definition console_key.hpp:114
@ k
The K key.
Definition console_key.hpp:108
@ b
The B key.
Definition console_key.hpp:90
@ x
The X key.
Definition console_key.hpp:134
Contains xtd::collections::generic::helpers::hasher struct.
Contains iteraors aliases.
The xtd::collections::generic namespace contains interfaces and classes that define generic collectio...
Definition comparer.hpp:16
The xtd::collections namespace contains interfaces and classes that define various collections of obj...
Definition any_pair.hpp:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
Contains xtd::new_ptr method.
Represents the dictionary equator type.
Definition dictionary.hpp:104
bool operator()(const key_t &a, const key_t &b) const
checks if the specified a and b keys are equal.
Definition dictionary.hpp:124
key_t first_argument_type
Represents the first argument type.
Definition dictionary.hpp:109
bool result_type
Represents the result type.
Definition dictionary.hpp:113
key_t second_argument_type
Represents the second argument type.
Definition dictionary.hpp:111
Represents the dictionary hasher type.
Definition dictionary.hpp:73
key_t argument_type
Represents the argument type.
Definition dictionary.hpp:78
xtd::size result_type
Represents the result type.
Definition dictionary.hpp:80
size_t operator()(const key_t &key) const
Serves as a hash function for a specified key with a particular type (type_t).
Definition dictionary.hpp:90
Implements a function object for performing comparisons. Unless specialised, invokes operator== on ty...
Definition equator.hpp:38
Implements a function object for hashing data.
Definition hasher.hpp:39