70 for (
const auto& item : collection)
77 for (
const auto& item : collection)
88 for (
const auto& item : collection)
96 for (
const auto& item : collection)
109 for (
const auto& item : collection)
118 for (
const auto& item : collection)
135 items_.ensure_capacity(items.size());
136 for (
const auto& [key, value] : items)
137 items_.add(key, value);
144 items_.ensure_capacity(items.size());
145 for (
const auto& item : items)
158 return items_.comparer();
165 return items_.count();
172 [[nodiscard]]
auto is_empty() const noexcept ->
bool {
174 return items_.is_empty();
181 [[nodiscard]]
auto is_read_only() const noexcept ->
bool override {
return false;}
204 return items_.keys();
213 return items_.values();
229 if (!items_.contains_key(key)) items_.add(key, add_value_factory(key));
230 else items_[key] = update_value_factory(key, items_[key]);
242 if (!items_.contains_key(key)) items_.add(key, add_value);
243 else items_[key] = update_value_factory(key, items_[key]);
255 template<
typename arg_t>
258 if (!items_.contains_key(key)) items_.add(key, add_value_factory(key, factory_argument));
259 else items_[key] = update_value_factory(key, items_[key], factory_argument);
276 return items_.contains_key(key);
286 items_.copy_to(
array, array_index);
295 return items.get_enumerator();
304 if (!items_.contains_key(key)) items_.add(key, add_value_factory(key));
313 [[nodiscard]]
auto get_or_add(
const key_t& key,
const value_t& add_value) ->
const value_t& {
315 if (!items_.contains_key(key)) items_.add(key, add_value);
325 template<
typename arg_t>
328 if (!items_.contains_key(key)) items_.add(key, add_value_factory(key, factory_argument));
339 return items_.to_array();
345 [[nodiscard]]
auto to_string() const noexcept ->
xtd::
string override {
353 auto try_add(
const key_t& key,
const value_t& value) ->
bool {
355 if (items_.contains_key(key))
return false;
356 items_.add(key, value);
365 auto try_get_value(
const key_t& key, value_t& value)
const ->
bool override {
367 return items_.try_get_value(key, value);
375 auto value = value_t {};
384 if (!items_.try_get_value(key, value))
return false;
385 return items_.remove(key);
396 if (!items_.contains(item))
return false;
397 return items_.remove(item);
407 auto try_update(
const key_t& key,
const value_t& new_value,
const value_t& comparison_value) ->
bool {
409 if (!items_.contains({key, comparison_value}))
return false;
410 items_[key] = new_value;
427 auto operator [](
const key_t& key)
const ->
const value_t&
override {
429 return items_.operator [](key);
440 return items_.operator [](key);
452 auto add(
const key_t& key,
const value_t& value) ->
void override {
454 items_.
add(key, value);
463 auto remove(
const xtd::collections::generic::key_value_pair<key_t, value_t>& item) ->
bool override {
465 return items_.remove(item);
469 auto remove(
const key_t& key)
noexcept ->
bool override {
471 return items_.remove(key);
482 template<
typename key_t,
typename value_t >
485 template<
typename key_t,
typename value_t >
488 template<xtd::iterable iterable_t>
491 template<
typename key_t,
typename value_t >
494 template<
typename key_t,
typename value_t >
497 template<
typename input_iterator_t >
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents a thread-safe collection of key/value pairs that can be accessed by multiple threads concu...
Definition concurrent_dictionary.hpp:37
auto clear() -> void override
Removes all keys and values from the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:266
auto get_enumerator() const -> xtd::collections::generic::enumerator< value_type > override
Returns an enumerator that iterates through a collection.
Definition concurrent_dictionary.hpp:292
concurrent_dictionary(xtd::iterable auto &&collection, const xtd::collections::generic::iequality_comparer< key_type > &comparer)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:94
auto try_update(const key_t &key, const value_t &new_value, const value_t &comparison_value) -> bool
Updates the value associated with key to new_value if the existing value with key is equal to compari...
Definition concurrent_dictionary.hpp:407
auto is_empty() const noexcept -> bool
Gets a value that indicates whether the xtd::collections::concurrent::concurrent_dictionary <key_t,...
Definition concurrent_dictionary.hpp:172
concurrent_dictionary(const xtd::collections::generic::iequality_comparer< key_type > &comparer)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:82
auto is_read_only() const noexcept -> bool override
Gets a value indicating whether the xtd::collections::concurrent::concurrent_dictionary <key_t,...
Definition concurrent_dictionary.hpp:181
auto get_or_add(const key_t &key, const value_t &add_value) -> const value_t &
Adds a key/value pair to the xtd::collections::concurrent::concurrent_dictionary <key_t,...
Definition concurrent_dictionary.hpp:313
typename xtd::collections::generic::idictionary< key_t, value_t >::key_type key_type
Represents the dictionary key type.
Definition concurrent_dictionary.hpp:43
concurrent_dictionary(xtd::usize concurrent_level, xtd::usize capacity, const xtd::collections::generic::iequality_comparer< key_type > &comparer)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:125
concurrent_dictionary(xtd::usize concurrent_level, xtd::collections::generic::ienumerable< value_type > &&collection, const xtd::collections::generic::iequality_comparer< key_type > &comparer)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:107
auto try_remove(const key_t &key, value_t &value) -> bool
Attempts to remove and return the value that has the specified key from the xtd::collections::concurr...
Definition concurrent_dictionary.hpp:382
auto keys() const noexcept -> key_collection override
Gets a collection containing the keys in the xtd::collections::generic::ictionary<key_t,...
Definition concurrent_dictionary.hpp:202
typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_type value_type
Represents the dictionary value type.
Definition concurrent_dictionary.hpp:47
auto try_remove(const xtd::collections::generic::key_value_pair< key_t, value_t > &item) -> bool
Removes a key and value from the dictionary. @pram item The xtd::collections::generic::key_value_pair...
Definition concurrent_dictionary.hpp:394
auto get_or_add(const key_t &key, xtd::callable< value_t, key_t > auto &&add_value_factory) -> const value_t &
Adds a key/value pair to the xtd::collections::concurrent::concurrent_dictionary <key_t,...
Definition concurrent_dictionary.hpp:302
auto count() const noexcept -> xtd::usize override
Gets the number of elements contained in the xtd::collections::generic::icollection.
Definition concurrent_dictionary.hpp:163
const value_type & const_reference
Represents the const reference of list value type.
Definition concurrent_dictionary.hpp:51
concurrent_dictionary(xtd::usize concurrent_level, xtd::iterable auto &&collection, const xtd::collections::generic::iequality_comparer< key_type > &comparer)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:116
auto try_remove(const key_t &key) -> bool
Attempts to remove and return the value that has the specified key from the xtd::collections::concurr...
Definition concurrent_dictionary.hpp:374
concurrent_dictionary(xtd::iterable auto &&collection)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:75
auto to_array() const -> xtd::array< value_type >
Copies the elements contained in the xtd::collections::concurrent::concurrent_dictionary <key_t,...
Definition concurrent_dictionary.hpp:337
auto add_or_update(const key_t &key, xtd::callable< value_t, key_t, arg_t > auto &&add_value_factory, xtd::callable< value_t, key_t, value_t, arg_t > auto &&update_value_factory, arg_t &&factory_argument) -> const value_t &
Uses the specified functions and argument to add a key/value pair to the xtd::collections::concurrent...
Definition concurrent_dictionary.hpp:256
auto values() const noexcept -> value_collection override
Gets a collection that contains the values in the xtd::collections::generic::ictionary<key_t,...
Definition concurrent_dictionary.hpp:211
auto is_synchronized() const noexcept -> bool override
Gets a value indicating whether access to the xtd::collections::concurrent::concurrent_dictionary <ke...
Definition concurrent_dictionary.hpp:197
auto add_or_update(const key_t &key, xtd::callable< value_t, key_t > auto &&add_value_factory, xtd::callable< value_t, key_t, value_t > auto &&update_value_factory) -> const value_t &
Uses the specified functions to add a key/value pair to the xtd::collections::concurrent::concurrent_...
Definition concurrent_dictionary.hpp:227
auto try_add(const key_t &key, const value_t &value) -> bool
Attempts to add the specified key and value to the xtd::collections::concurrent::concurrent_dictionar...
Definition concurrent_dictionary.hpp:353
auto try_get_value(const key_t &key, value_t &value) const -> bool override
Attempts to get the value associated with the specified key from the xtd::collections::concurrent::co...
Definition concurrent_dictionary.hpp:365
auto add_or_update(const key_t &key, const value_t &add_value, xtd::callable< value_t, key_t, value_t > auto &&update_value_factory) -> const value_t &
Adds a key/value pair to the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:240
auto to_string() const noexcept -> xtd::string override
Returns a xtd::string that represents the current object.
Definition concurrent_dictionary.hpp:345
concurrent_dictionary()=default
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
auto copy_to(xtd::array< value_type > &array, xtd::usize array_index) const -> void override
Copies the elements of the xtd::collections::concurrent::concurrent_dictionary <key_t,...
Definition concurrent_dictionary.hpp:284
concurrent_dictionary(xtd::usize concurrent_level, xtd::usize capacity)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:102
concurrent_dictionary(xtd::collections::generic::ienumerable< value_type > &&collection, const xtd::collections::generic::iequality_comparer< key_type > &comparer)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:86
typename xtd::collections::generic::idictionary< key_t, value_t >::mapped_type mapped_type
Represents the dictionary mapped type.
Definition concurrent_dictionary.hpp:45
auto comparer() const noexcept -> const xtd::collections::generic::iequality_comparer< key_t > &
Gets the xtd::collections::generic::iequality_comparer <type_t> that is used to determine equality of...
Definition concurrent_dictionary.hpp:157
concurrent_dictionary(std::initializer_list< value_type > items)
Constructs the container with the contents of the specified initializer list, and allocator.
Definition concurrent_dictionary.hpp:142
typename xtd::collections::generic::idictionary< key_type, mapped_type >::value_collection value_collection
Represents the idictionary value collection type.
Definition concurrent_dictionary.hpp:57
auto operator[](const key_t &key) const -> const value_t &override
Gets the element with the specified key.
Definition concurrent_dictionary.hpp:427
auto get_or_add(const key_t &key, xtd::callable< value_t, key_t, arg_t > auto &&add_value_factory, arg_t &&factory_argument) -> const value_t &
Adds a key/value pair to the xtd::collections::concurrent::concurrent_dictionary <key_t,...
Definition concurrent_dictionary.hpp:326
value_type & reference
Represents the reference of list value type.
Definition concurrent_dictionary.hpp:49
xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t > collection_type
Represents the concurrent bag collection type.
Definition concurrent_dictionary.hpp:53
typename xtd::collections::generic::idictionary< key_type, mapped_type >::key_collection key_collection
Represents the idictionary key collection type.
Definition concurrent_dictionary.hpp:55
concurrent_dictionary(std::initializer_list< std::pair< key_t, value_t > > items)
Initializes instance of the xtd::collections::generic::dictionary <key_t, value_t> class from a varie...
Definition concurrent_dictionary.hpp:133
auto contains_key(const key_t &key) const noexcept -> bool override
Determines whether the xtd::collections::concurrent::concurrent_dictionary<key_t,value_t> contains th...
Definition concurrent_dictionary.hpp:274
concurrent_dictionary(xtd::collections::generic::ienumerable< value_type > &&collection)
Initializes a new instance of the xtd::collections::concurrent::concurrent_dictionary<key_t,...
Definition concurrent_dictionary.hpp:68
Represents a collection of keys and values.
Definition dictionary.hpp:63
auto contains(const value_type &item) const noexcept -> bool override
Determines whether an element is in the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:353
auto add(const key_t &key, const value_t &value) -> void override
Adds an element with the provided key and value to the xtd::collections::generic::dictionary <key_t,...
Definition dictionary.hpp:332
Represents a generic collection of key/value pairs.
Definition idictionary.hpp:47
xtd::collections::generic::list< mapped_type > value_collection
Definition idictionary.hpp:65
xtd::collections::generic::list< key_type > key_collection
Definition idictionary.hpp:63
virtual auto sync_root() const noexcept -> const xtd::object &=0
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollecti...
xtd::any_object key_type
Definition idictionary.hpp:53
xtd::any_object mapped_type
Definition idictionary.hpp:55
typename xtd::collections::generic::icollection< xtd::collections::generic::key_value_pair< xtd::any_object, xtd::any_object > >::value_type value_type
Definition idictionary.hpp:57
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:46
Defines methods to support the comparison of objects for equality.
Definition iequality_comparer.hpp:34
static auto processor_count() -> xtd::usize
Gets the number of processors on the current machine.
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:40
Definition callable.hpp:11
Definition iterable.hpp:15
Contains xtd::collections::generic::dictionary <key_t, value_t> class.
Contains xtd::environment class.
generic::enumerator< xtd::any_object > enumerator
Supports a simple iteration over a non-generic collection.
Definition enumerator.hpp:28
generic::iequality_comparer< xtd::any_object > iequality_comparer
Defines methods to support the comparison of objects for equality.
Definition iequality_comparer.hpp:29
static auto unreachable() -> void
The function unreachable expands to a void expression. Executing unreachable() results in undefined b...
Definition environment.hpp:742
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
#define lock_guard_(object)
The lock_guard_ keyword marks a statement block_guard as a critical section by obtaining the mutual-e...
Definition lock_guard.hpp:65
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
auto as(any_object &o) -> type_t
Casts a type into another type.
Definition __as_any_object.hpp:60
Contains xtd::collections::concurrent::iproducer_consumer_collection <type_t> interface.
Provides several thread-safe collection classes that should be used in place of the corresponding typ...
Definition concurrent_bag.hpp:20
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
Contains xtd::object class.
Defines a key/value pair that can be set or retrieved.
Definition key_value_pair.hpp:37
Contains xtd::threading::lock_guard class.