xtd 1.0.0
Loading...
Searching...
No Matches
xtd::collections::generic::icollection< type_t > Class Template Referenceabstract
Inheritance diagram for xtd::collections::generic::icollection< type_t >:
xtd::collections::generic::ienumerable< type_t > xtd::collections::generic::extensions::collection_common< type_t, icollection< type_t > > xtd::interface xtd::collections::generic::ienumerable_abstract xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > > xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t > xtd::collections::generic::idictionary< xtd::any_object, xtd::any_object > xtd::collections::generic::linked_list< type_t > xtd::forms::layout::arranged_element_collection< xtd::string > xtd::forms::layout::arranged_element_collection< item > xtd::forms::layout::arranged_element_collection< xtd::forms::control_ref > xtd::forms::layout::arranged_element_collection< drawing::image > xtd::forms::layout::arranged_element_collection< xtd::forms::link_label::link > xtd::forms::layout::arranged_element_collection< item, item::sorter > xtd::forms::layout::arranged_element_collection< xtd::forms::menu_item_ref > xtd::forms::layout::arranged_element_collection< xtd::forms::message_notifier_button_ref > xtd::forms::layout::arranged_element_collection< status_bar_panel_ref > xtd::forms::layout::arranged_element_collection< tab_page_ref > xtd::forms::layout::arranged_element_collection< tool_bar_button_ref > xtd::collections::concurrent::iproducer_consumer_collection< type_t > xtd::collections::generic::ilist< type_t > xtd::collections::generic::linked_list< type_t, allocator_t > xtd::collections::generic::queue< type_t, container_t > xtd::collections::generic::stack< type_t, container_t > xtd::forms::layout::arranged_element_collection< type_t, sorter_t >

Definition

template<typename type_t>
class xtd::collections::generic::icollection< type_t >

Defines methods to manipulate generic collections.

Definition
template<typename type_t>
Internal collection common definition.
Definition collection_common.hpp:32
Defines methods to manipulate generic collections.
Definition icollection.hpp:45
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
Header
#include <xtd/collections/generic/icollection>
Namespace
xtd::collections::generic
Library
xtd.core
Examples
The following example implements the xtd::collections::generic::icollection <type_t> interface to create a collection of custom box objects named box_collection. Each box has height, length, and width properties, which are used to define equality. Equality can be defined as all dimensions being the same or the volume being the same. The box class implements the xtd::iequatable <type_t> interface to define the default equality as the dimensions being the same.

The box_collection class implements the xtd::collections::generic::icollection::contains method to use the default equality to determine whether a box is in the collection. This method is used by the xtd::collections::generic::icollection::add method so that each box added to the collection has a unique set of dimensions. The box_collection class also provides an overload of the xtd::collections::generic::icollection::contains method that takes a specified xtd::collections::generic::iequality_comparer <type_t> interface, such as box_same_dimensions and box_same_volume classes in the example.

This example also implements an xtd::collections::generic::ienumerator <type_t> interface for the box_collection class so that the collection can be enumerated.

#include <xtd/xtd>
class program {
public:
static auto main() -> void {
auto boxes = box_collection {};
boxes.add(program::box {10, 4, 6});
boxes.add(program::box {4, 6, 10});
boxes.add(program::box {6, 10, 4});
boxes.add(program::box {12, 8, 10});
// Same dimensions. Cannot be added:
boxes.add(program::box {10, 4, 6});
// Test the Remove method.
display(boxes);
console::write_line("Removing 6x10x4");
boxes.remove(program::box {6, 10, 4});
display(boxes);
// Test the Contains method.
auto box_check = program::box {8, 12, 10};
console::write_line("Contains {}x{}x{} by dimensions: {}", box_check.height, box_check.length, box_check.width, boxes.contains(box_check));
// Test the Contains method overload with a specified equality comparer.
console::write_line("Contains {}x{}x{} by volume: {}", box_check.height, box_check.length, box_check.width, boxes.contains(box_check, box_same_volume {}));
}
struct box : public object, public iequatable<program::box> {
// Public Constructors :
box() = default;
box(int h, int l, int w) : height {h}, length{l}, width {w} {}
// Public Properties :
int height = 0;
int length = 0;
int width = 0;
// Public Methods :
bool equals(const object& o) const noexcept override {return is<program::box>(o) && equals(as<program::box>(o));}
bool equals(const program::box& o) const noexcept override {return box_same_dimensions {}.equals(*this, o);}
};
class box_collection : public icollection<program::box> {
public:
// Public Constructors :
box_collection(const std::initializer_list<program::box>& boxes) : boxes_(boxes) {}
// Public Properties :
usize count() const noexcept override {return boxes_.count();}
bool is_read_only() const noexcept override {return false;}
bool is_synchronized() const noexcept override {return false;}
const object& sync_root() const noexcept override {return sync_root_;}
// Public Methods :
void add(const program::box& item) override {
if (!contains(item))
boxes_.add(item);
else
console::write_line("A box with {}x{}x{} dimensions was already added to the collection.", item.height, item.length, item.width);
}
void clear() override {boxes_.clear();}
bool contains(const program::box& item) const noexcept override {return boxes_.contains(item);}
bool contains(const program::box& item, const iequality_comparer<program::box>& comparer) const noexcept {
for (auto box : boxes_)
if (comparer.equals(box, item)) return true;
return false;
}
void copy_to(array<program::box>& array, usize array_index) const override {boxes_.copy_to(array, array_index);}
enumerator<program::box> get_enumerator() const override {return {new_ptr<box_enumerator>(boxes_)};}
bool remove(const program::box& item) override {return boxes_.remove(item);}
private:
list<program::box> boxes_;
object sync_root_;
};
class box_enumerator : public ienumerator<program::box> {
public:
// Public Constructors :
explicit box_enumerator(const list<program::box>& items) : items_(items) {}
// Public Properties :
const program::box& current() const override {return items_[index_];}
// Public Methods :
bool move_next() override {return ++index_ < items_.count();}
void reset() override {index_ = usize_object::max_value;}
protected:
const list<program::box>& items_;
usize index_ = usize_object::max_value;
};
// Defines two boxes as equal if they have the same dimensions.
class box_same_dimensions : public iequality_comparer<program::box> {
public:
// Public Methods :
bool equals(const program::box& b1, const program::box& b2) const noexcept override {return b1.height == b2.height && b1.length == b2.length && b1.width == b2.width;}
usize get_hash_code(const program::box& box) const noexcept override {return hash_code::combine(box.height, box.length, box.width);}
};
// Defines two boxes as equal if they have the same volume.
class box_same_volume : public iequality_comparer<program::box> {
public:
// Public Methods :
bool equals(const program::box& b1, const program::box& b2) const noexcept override {return b1.height * b1.length * b1.width == b2.height * b2.length * b2.width;}
usize get_hash_code(const program::box& box) const noexcept override {
auto hash_code = hash_code::combine(box.height, box.length, box.width);
console::write_line("HC: {}", hash_code);
return hash_code;
}
};
static void display(const box_collection& boxes) {
console::write_line("\nheight length width hash code");
for (auto box : boxes)
console::write_line("{,-6} {,-6} {,-6} {}", box.height, box.length, box.width, box.get_hash_code());
// Results by manipulating the enumerator directly:
//auto enumerator = boxes.get_enumerator();
//console::write_line("\nheight length width hash code");
//while (enumerator.move_next()) {
// auto b = enumerator.current();
// console::write_line("{,-6} {,-6} {,-6} {}", b.height, b.length, b.width, b.get_hash_code());
//}
}
};
startup_(program::main);
// This code can produce the following output :
//
// A box with 10x4x6 dimensions was already added to the collection.
//
// height length width hash code
// 10 4 6 215240349697
// 4 6 10 215240349697
// 6 10 4 215240349697
// 12 8 10 215240349697
//
// Removing 6x10x4
//
// height length width hash code
// 10 4 6 215240349697
// 4 6 10 215240349697
// 12 8 10 215240349697
//
// Contains 8x12x10 by dimensions: false
// Contains 8x12x10 by volume: true
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
virtual auto equals(const object &obj) const noexcept -> bool
Determines whether the specified object is equal to the current object.
generic::icollection< xtd::any_object > icollection
Defines size, enumerators, and synchronization methods for all nongeneric collections.
Definition icollection.hpp:32
xtd::collections::generic::comparer< xtd::any_object > comparer
Exposes a method that compares two objects.
Definition comparer.hpp:25
generic::ienumerator< xtd::any_object > ienumerator
Supports a simple iteration over a non-generic collection.
Definition ienumerator.hpp:38
generic::iequality_comparer< xtd::any_object > iequality_comparer
Defines methods to support the comparison of objects for equality.
Definition iequality_comparer.hpp:29
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:284
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
@ current
Specifies the current position within a stream.
Definition seek_origin.hpp:20
@ clear
The CLEAR key.
Definition console_key.hpp:26
@ h
The H key.
Definition console_key.hpp:102
@ l
The L key.
Definition console_key.hpp:110
@ add
The Add key.
Definition console_key.hpp:170
@ w
The W key.
Definition console_key.hpp:132
@ display
Specifies 1/75 inch as the unit of measure.
Definition graphics_unit.hpp:21
@ height
Specifies that the height of the control is defined.
Definition bounds_specified.hpp:34
@ width
Specifies that the width of the control is defined.
Definition bounds_specified.hpp:32
auto equals(const object &obj) const noexcept -> bool override
Determines whether the specified object is equal to the current object.
Definition read_only_span.hpp:239
constexpr auto length() const noexcept -> size_type
Returns the length of the current read_only_span.
Definition read_only_span.hpp:213
auto get_hash_code() const noexcept -> xtd::usize override
Serves as a hash function for a particular type.
Definition read_only_span.hpp:263
auto copy_to(span< type_t, length > &destination) const -> void
Copies the contents of this xtd::read_only_span <type_t> into a destination xtd:span <type_t>.
Definition read_only_span.hpp:231
Remarks
The xtd::collections::generic::icollection <type_t> interface is the base interface for classes in the xtd::collections::generic namespace.
The xtd::collections::generic::icollection <type_t> interface extends xtd::collections::generic::ienumerable <type_t>; xtd::collections::generic::idictionary <key_t, value_t> and xtd::collections::generic::ilist <type_t> are more specialized interfaces that extend xtd::collections::generic::icollection <type_t>. A xtd::collections::generic::idictionary <key_t, value_t> implementation is a collection of key/value pairs, like the xtd::collections::generic::dictoinary <key_t, value_t> class. A xtd::collections::generic::ilist <type_t> implementation is a collection of values, and its members can be accessed by index, like the xtd::collections::generic::list <type_t> class.
If neither the xtd::collections::generic::idictionary <key_t, value_t> interface nor the xtd::collections::generic::ilist <type_t> interface meet the requirements of the required collection, derive the new collection class from the xtd::collections::generic::icollection <type_t> interface instead for more flexibility.

Public Aliases

using value_type
 Represents the xtd::collections::generic::icollection value type.

Public Properties

virtual auto count () const noexcept -> xtd::usize=0
 Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
virtual auto is_read_only () const noexcept -> bool=0
 Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
virtual auto is_synchronized () const noexcept -> bool=0
 Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe).
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::icollection <type_t>.

Public Methods

virtual auto add (const type_t &item) -> void=0
 Adds an item to the xtd::collections::generic::icollection <type_t>.
virtual auto clear () -> void=0
 Removes all items from the xtd::collections::generic::icollection <type_t>.
virtual auto contains (const type_t &item) const noexcept -> bool=0
 Determines whether the xtd::collections::generic::icollection <type_t> contains a specific value.
virtual auto copy_to (xtd::array< type_t > &array, xtd::usize array_index) const -> void=0
 Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.
virtual auto get_enumerator () const -> xtd::collections::generic::enumerator< type_t >=0
 Returns an enumerator that iterates through a collection.
virtual auto remove (const type_t &item) -> bool=0
 Removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.

Additional Inherited Members

using value_type
 Represents the xtd::collections::generic::ienumerable value type.
using iterator
 Represents the iterator of xtd::collections::generic::ienumerable value type.
using const_iterator
 Represents the const iterator of xtd::collections::generic::ienumerable value type.
using iterator
 Represents the iterator of enumerable value type.
using const_iterator
 Represents the const iterator of enumerable value type.
using enumerable_type
 Represents the ienumerable enumerable type.
using source_type
 Represents the ienumerable source type.
using ienumerable
 Represents the ienumerable value type.
using list
 Represents the list value type.
virtual auto begin () const -> const_iterator
 Returns an iterator to the first element of the enumerable.
virtual auto cbegin () const -> const_iterator
 Returns an iterator to the first element of the enumerable.
virtual auto cend () const -> const_iterator
 Returns an iterator to the element following the last element of the enumerable.
virtual auto end () const -> const_iterator
 Returns an iterator to the element following the last element of the enumerable.
auto aggregate (const std::function< type_t(const type_t &, const type_t &)> &funcfunc) const -> type_t
 Applies an accumulator function over a sequence.
auto all (const std::function< bool(const type_t &)> &predicatepredicate) const -> bool
 Determines whether all elements of a sequence satisfy a condition.
auto any () const noexcept -> bool
 Determines whether a sequence contains any elements.
auto append (const type_t &element) const noexcept
 Appends a value to the end of the sequence.
auto as_enumerable () const noexcept
 Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
auto average () const noexcept
 Computes the average of a sequence of source_t values.
auto cast () const noexcept
 Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
auto chunk (xtd::usize size) const
 Splits the elements of a sequence into chunks of size at most size.
auto concat (const ienumerable< type_t > &second) const noexcept
 Concatenates two sequences.
auto contains (const type_t &value) const noexcept -> bool
 Determines whether a sequence contains a specified element by using the default equality comparer.
auto count () const noexcept -> xtd::usize
 Returns the number of elements in current sequence.
auto 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.
auto 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.
auto distinct () const noexcept
 Returns distinct elements from a sequence by using the default equality comparer to compare values.
auto first_or_default (const std::function< bool(const type_t &)> &predicatepredicate, const type_t &default_value) const noexcept -> type_t
 Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
auto order () const
 Sorts the elements of a sequence in ascending order.
auto order_by (const std::function< type_t(const type_t &)> &key_selector) const
 Sorts the elements of a sequence in ascending order according to a key.
auto order_by_descending (const std::function< key_t(const type_t &)> &key_selector) const
 Sorts the elements of a sequence in descending order according to a key.
auto select (auto &&selector) const
 Projects each element of a sequence into a new form.
auto to_array () const noexcept -> xtd::array< type_t >
 Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
auto to_list () const noexcept -> xtd::collections::generic::list< type_t >
 Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
auto where (auto &&predicatepredicate) const
 Filters a sequence of values based on a predicate.
virtual auto empty () const noexcept -> bool
 Checks whether the container is empty.
virtual auto size () const noexcept -> xtd::usize
 Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
virtual auto operator<< (const type_t &item) -> icollection< type_t > &
 The shift left operator adds an item to the xtd::collections::generic::icollection <type_t>.
virtual auto operator>> (const type_t &item) -> icollection< type_t > &
 The shift right operator removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
static auto to_const_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator
 Converts source iterator to target iterator.
static auto to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator
 Converts source iterator to target iterator.

Member Typedef Documentation

◆ value_type

template<typename type_t>
using xtd::collections::generic::icollection< type_t >::value_type

Represents the xtd::collections::generic::icollection value type.

Member Function Documentation

◆ count()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::count ( ) const -> xtd::usize
nodiscardpure virtualnoexcept

Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.

Returns
The number of elements contained in the xtd::collections::generic::icollection <type_t>.

Implemented in xtd::basic_array< type_t, allocator_t >, xtd::basic_array< byte, allocator_t >, xtd::basic_array< item_t, allocator_t >, xtd::basic_array< type_t, allocator_t >, xtd::basic_array< value_type, allocator_t >, xtd::basic_array< xtd::array< xtd::byte >, allocator_t >, xtd::basic_array< xtd::basic_string< char >, allocator_t >, xtd::basic_array< xtd::byte, allocator_t >, xtd::basic_array< xtd::drawing::imaging::encoder_parameter, allocator_t >, xtd::basic_array< xtd::net::ip_address, allocator_t >, xtd::basic_array< xtd::uint16, allocator_t >, xtd::collections::bit_array, xtd::collections::concurrent::concurrent_bag< type_t >, xtd::collections::concurrent::iproducer_consumer_collection< type_t >, xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< intptr, item >, xtd::collections::generic::dictionary< key_type, mapped_type >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::dictionary< xtd::intptr, xtd::ptr< collection_type > >, xtd::collections::generic::dictionary< xtd::string, xtd::any_object >, xtd::collections::generic::dictionary< xtd::string, xtd::string >, xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::idictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::ilist< xtd::uint16 >, xtd::collections::generic::linked_list< type_t, allocator_t >, xtd::collections::generic::linked_list< type_t >, xtd::collections::generic::linked_list< value_type >, xtd::collections::generic::list< type_t, allocator_t >, xtd::collections::generic::list< byte >, xtd::collections::generic::list< int32 >, xtd::collections::generic::list< item >, xtd::collections::generic::list< key_type >, xtd::collections::generic::list< mapped_type >, xtd::collections::generic::list< thread_pool_asynchronous_io_item >, xtd::collections::generic::list< thread_pool_item >, xtd::collections::generic::list< value_type >, xtd::collections::generic::list< xtd::any_object >, xtd::collections::generic::list< xtd::byte >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::color > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::font > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::font_family > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::string > >, xtd::collections::generic::list< xtd::drawing::color >, xtd::collections::generic::list< xtd::drawing::drawing_2d::gradient_stop >, xtd::collections::generic::list< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::list< xtd::forms::style_sheets::shadow >, xtd::collections::generic::list< xtd::ref< xtd::forms::form > >, xtd::collections::generic::list< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::list< xtd::string >, xtd::collections::generic::list< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::list< xtd::tunit::test >, xtd::collections::generic::list< xtd::usize >, xtd::collections::generic::list< xtd_library >, xtd::collections::generic::ordered_dictionary< key_t, value_t, allocator_t >, xtd::collections::generic::ordered_dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::queue< type_t, container_t >, xtd::collections::generic::queue< value_type >, xtd::collections::generic::queue< xtd::any_object >, xtd::collections::generic::stack< type_t, container_t >, xtd::collections::generic::stack< xtd::any_object >, xtd::collections::object_model::read_only_collection< type_t >, xtd::collections::object_model::read_only_collection< value_type >, xtd::forms::layout::arranged_element_collection< type_t, sorter_t >, xtd::forms::layout::arranged_element_collection< drawing::image >, xtd::forms::layout::arranged_element_collection< item >, xtd::forms::layout::arranged_element_collection< item, item::sorter >, xtd::forms::layout::arranged_element_collection< status_bar_panel_ref >, xtd::forms::layout::arranged_element_collection< tab_page_ref >, xtd::forms::layout::arranged_element_collection< tool_bar_button_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::control_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::link_label::link >, xtd::forms::layout::arranged_element_collection< xtd::forms::menu_item_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::message_notifier_button_ref >, and xtd::forms::layout::arranged_element_collection< xtd::string >.

◆ is_read_only()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::is_read_only ( ) const -> bool
nodiscardpure virtualnoexcept

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 xtd::collections::generic::icollection::is_read_only 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.

Implemented in xtd::basic_array< type_t, allocator_t >, xtd::basic_array< byte, allocator_t >, xtd::basic_array< item_t, allocator_t >, xtd::basic_array< type_t, allocator_t >, xtd::basic_array< value_type, allocator_t >, xtd::basic_array< xtd::array< xtd::byte >, allocator_t >, xtd::basic_array< xtd::basic_string< char >, allocator_t >, xtd::basic_array< xtd::byte, allocator_t >, xtd::basic_array< xtd::drawing::imaging::encoder_parameter, allocator_t >, xtd::basic_array< xtd::net::ip_address, allocator_t >, xtd::basic_array< xtd::uint16, allocator_t >, xtd::collections::concurrent::concurrent_bag< type_t >, xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::idictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, and xtd::collections::generic::ilist< xtd::uint16 >.

◆ is_synchronized()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::is_synchronized ( ) const -> bool
nodiscardpure virtualnoexcept

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 (const auto& item : my_collection) {
// Insert your code here.
}
}
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...
#define lock_(object)
The lock_ keyword marks a statement block as a critical section by obtaining the mutual-exclusion loc...
Definition lock.hpp:68

Implemented in xtd::basic_array< type_t, allocator_t >, xtd::basic_array< byte, allocator_t >, xtd::basic_array< item_t, allocator_t >, xtd::basic_array< type_t, allocator_t >, xtd::basic_array< value_type, allocator_t >, xtd::basic_array< xtd::array< xtd::byte >, allocator_t >, xtd::basic_array< xtd::basic_string< char >, allocator_t >, xtd::basic_array< xtd::byte, allocator_t >, xtd::basic_array< xtd::drawing::imaging::encoder_parameter, allocator_t >, xtd::basic_array< xtd::net::ip_address, allocator_t >, xtd::basic_array< xtd::uint16, allocator_t >, xtd::collections::concurrent::concurrent_bag< type_t >, xtd::collections::concurrent::iproducer_consumer_collection< type_t >, xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::idictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, and xtd::collections::generic::ilist< xtd::uint16 >.

◆ sync_root()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::sync_root ( ) const -> const xtd::object &
nodiscardpure virtualnoexcept

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 (const auto& item : my_collection) {
// Insert your code here.
}
}
Defines the base class for predefined exceptions in the xtd namespace.
Definition exception.hpp:29
Definition enumeration.hpp:12
auto is(xtd::any value) -> bool
Checks if the result of an expression is compatible with a given type.
Definition is.hpp:485
@ other
The operating system is other.
Definition platform_id.hpp:60
@ a
The A key.
Definition console_key.hpp:88
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:39

Implemented in xtd::basic_array< type_t, allocator_t >, xtd::basic_array< byte, allocator_t >, xtd::basic_array< item_t, allocator_t >, xtd::basic_array< type_t, allocator_t >, xtd::basic_array< value_type, allocator_t >, xtd::basic_array< xtd::array< xtd::byte >, allocator_t >, xtd::basic_array< xtd::basic_string< char >, allocator_t >, xtd::basic_array< xtd::byte, allocator_t >, xtd::basic_array< xtd::drawing::imaging::encoder_parameter, allocator_t >, xtd::basic_array< xtd::net::ip_address, allocator_t >, xtd::basic_array< xtd::uint16, allocator_t >, xtd::collections::concurrent::iproducer_consumer_collection< type_t >, xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::idictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::ilist< xtd::uint16 >, xtd::collections::object_model::read_only_collection< type_t >, and xtd::collections::object_model::read_only_collection< value_type >.

◆ add()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::add ( const type_t & item) -> void
pure virtual

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.

Implemented in xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::ilist< xtd::uint16 >, xtd::collections::generic::list< type_t, allocator_t >, xtd::collections::generic::list< byte >, xtd::collections::generic::list< int32 >, xtd::collections::generic::list< value_type >, xtd::collections::generic::list< xtd::any_object >, xtd::collections::generic::list< xtd::byte >, xtd::collections::generic::list< xtd::drawing::color >, xtd::collections::generic::list< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::list< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::list< xtd::time_zone_info::adjustment_rule >, and xtd::forms::layout::arranged_element_collection< type_t, sorter_t >.

◆ clear()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::clear ( ) -> void
pure virtual

Removes all items from the xtd::collections::generic::icollection <type_t>.

Exceptions
xtd::not_supported_exceptionThe xtd::collections::generic::icollection <type_t> is read-only.
Remarks
xtd::collections::generic::icollection::count must be set to 0, and references to other objects from elements of the collection must be released.

Implemented in xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< intptr, item >, xtd::collections::generic::dictionary< key_type, mapped_type >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::dictionary< xtd::intptr, xtd::ptr< collection_type > >, xtd::collections::generic::dictionary< xtd::string, xtd::any_object >, xtd::collections::generic::dictionary< xtd::string, xtd::string >, xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::idictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::ilist< xtd::uint16 >, xtd::collections::generic::linked_list< type_t, allocator_t >, xtd::collections::generic::linked_list< type_t >, xtd::collections::generic::linked_list< value_type >, xtd::collections::generic::list< type_t, allocator_t >, xtd::collections::generic::list< byte >, xtd::collections::generic::list< int32 >, xtd::collections::generic::list< item >, xtd::collections::generic::list< key_type >, xtd::collections::generic::list< mapped_type >, xtd::collections::generic::list< thread_pool_asynchronous_io_item >, xtd::collections::generic::list< thread_pool_item >, xtd::collections::generic::list< value_type >, xtd::collections::generic::list< xtd::any_object >, xtd::collections::generic::list< xtd::byte >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::color > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::font > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::font_family > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::string > >, xtd::collections::generic::list< xtd::drawing::color >, xtd::collections::generic::list< xtd::drawing::drawing_2d::gradient_stop >, xtd::collections::generic::list< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::list< xtd::forms::style_sheets::shadow >, xtd::collections::generic::list< xtd::ref< xtd::forms::form > >, xtd::collections::generic::list< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::list< xtd::string >, xtd::collections::generic::list< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::list< xtd::tunit::test >, xtd::collections::generic::list< xtd::usize >, xtd::collections::generic::list< xtd_library >, xtd::collections::generic::ordered_dictionary< key_t, value_t, allocator_t >, xtd::collections::generic::ordered_dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::queue< type_t, container_t >, xtd::collections::generic::queue< value_type >, xtd::collections::generic::queue< xtd::any_object >, xtd::collections::generic::stack< type_t, container_t >, xtd::collections::generic::stack< xtd::any_object >, xtd::forms::layout::arranged_element_collection< type_t, sorter_t >, xtd::forms::layout::arranged_element_collection< drawing::image >, xtd::forms::layout::arranged_element_collection< item >, xtd::forms::layout::arranged_element_collection< item, item::sorter >, xtd::forms::layout::arranged_element_collection< status_bar_panel_ref >, xtd::forms::layout::arranged_element_collection< tab_page_ref >, xtd::forms::layout::arranged_element_collection< tool_bar_button_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::control_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::link_label::link >, xtd::forms::layout::arranged_element_collection< xtd::forms::menu_item_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::message_notifier_button_ref >, and xtd::forms::layout::arranged_element_collection< xtd::string >.

◆ contains()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::contains ( const type_t & item) const -> bool
nodiscardpure virtualnoexcept

Determines whether the xtd::collections::generic::icollection <type_t> contains a specific value.

Parameters
itemThe object to locate in the xtd::collections::generic::icollection <type_t>.
Returns
true if item is found in the xtd::collections::generic::icollection <type_t>; otherwise, false.
Remarks
Implementations can vary in how they determine equality of objects; for example, xtd::collections::generic::list <type_t> uses xtd::collections::generic::compoarer <type_t>::default_comparer, whereas xtd::collections::generic::dictionary <key_t, value_t> allows the user to specify the xtd::collections::generic::icompoarer <type_t> implementation to use for comparing keys.

Implemented in xtd::basic_array< type_t, allocator_t >, xtd::basic_array< byte, allocator_t >, xtd::basic_array< item_t, allocator_t >, xtd::basic_array< type_t, allocator_t >, xtd::basic_array< xtd::array< xtd::byte >, allocator_t >, xtd::basic_array< xtd::basic_string< char >, allocator_t >, xtd::basic_array< xtd::byte, allocator_t >, xtd::basic_array< xtd::drawing::imaging::encoder_parameter, allocator_t >, xtd::basic_array< xtd::net::ip_address, allocator_t >, xtd::basic_array< xtd::uint16, allocator_t >, xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::ilist< xtd::uint16 >, xtd::collections::generic::linked_list< type_t, allocator_t >, xtd::collections::generic::linked_list< type_t >, xtd::collections::generic::linked_list< value_type >, xtd::collections::generic::list< type_t, allocator_t >, xtd::collections::generic::list< byte >, xtd::collections::generic::list< int32 >, xtd::collections::generic::list< value_type >, xtd::collections::generic::list< xtd::any_object >, xtd::collections::generic::list< xtd::byte >, xtd::collections::generic::list< xtd::drawing::color >, xtd::collections::generic::list< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::list< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::list< xtd::time_zone_info::adjustment_rule >, xtd::collections::object_model::read_only_collection< type_t >, and xtd::forms::layout::arranged_element_collection< type_t, sorter_t >.

◆ copy_to()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::copy_to ( xtd::array< type_t > & array,
xtd::usize array_index ) const -> void
pure virtual

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`.

Implemented in xtd::array< type_t, 1, allocator_t >, xtd::basic_array< type_t, allocator_t >, xtd::collections::bit_array, xtd::collections::concurrent::iproducer_consumer_collection< type_t >, xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::ilist< xtd::uint16 >, xtd::collections::generic::linked_list< type_t, allocator_t >, xtd::collections::generic::linked_list< type_t >, xtd::collections::generic::linked_list< value_type >, xtd::collections::generic::list< type_t, allocator_t >, xtd::collections::generic::list< value_type >, xtd::collections::generic::list< xtd::any_object >, xtd::collections::generic::queue< type_t, container_t >, xtd::collections::generic::queue< value_type >, xtd::collections::generic::queue< xtd::any_object >, xtd::collections::generic::stack< type_t, container_t >, xtd::collections::generic::stack< xtd::any_object >, xtd::collections::object_model::read_only_collection< type_t >, and xtd::forms::layout::arranged_element_collection< type_t, sorter_t >.

◆ get_enumerator()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::get_enumerator ( ) const -> xtd::collections::generic::enumerator< type_t >
nodiscardpure virtual

Returns an enumerator that iterates through a collection.

Returns
An xtd::collections::generic::enumerator object that can be used to iterate through the collection.

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

Implemented in xtd::basic_array< type_t, allocator_t >, xtd::basic_array< byte, allocator_t >, xtd::basic_array< item_t, allocator_t >, xtd::basic_array< type_t, allocator_t >, xtd::basic_array< value_type, allocator_t >, xtd::basic_array< xtd::array< xtd::byte >, allocator_t >, xtd::basic_array< xtd::basic_string< char >, allocator_t >, xtd::basic_array< xtd::byte, allocator_t >, xtd::basic_array< xtd::drawing::imaging::encoder_parameter, allocator_t >, xtd::basic_array< xtd::net::ip_address, allocator_t >, xtd::basic_array< xtd::uint16, allocator_t >, xtd::collections::bit_array, xtd::collections::concurrent::concurrent_bag< type_t >, xtd::collections::concurrent::iproducer_consumer_collection< type_t >, xtd::collections::generic::dictionary< key_t, value_t, hasher_t, equator_t, allocator_t >, xtd::collections::generic::dictionary< intptr, item >, xtd::collections::generic::dictionary< key_type, mapped_type >, xtd::collections::generic::dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::dictionary< xtd::intptr, xtd::ptr< collection_type > >, xtd::collections::generic::dictionary< xtd::string, xtd::any_object >, xtd::collections::generic::dictionary< xtd::string, xtd::string >, xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::idictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::ilist< xtd::uint16 >, xtd::collections::generic::linked_list< type_t, allocator_t >, xtd::collections::generic::linked_list< type_t >, xtd::collections::generic::linked_list< value_type >, xtd::collections::generic::list< type_t, allocator_t >, xtd::collections::generic::list< byte >, xtd::collections::generic::list< int32 >, xtd::collections::generic::list< item >, xtd::collections::generic::list< key_type >, xtd::collections::generic::list< mapped_type >, xtd::collections::generic::list< thread_pool_asynchronous_io_item >, xtd::collections::generic::list< thread_pool_item >, xtd::collections::generic::list< value_type >, xtd::collections::generic::list< xtd::any_object >, xtd::collections::generic::list< xtd::byte >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::color > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::font > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::drawing::font_family > >, xtd::collections::generic::list< xtd::collections::generic::key_value_pair< xtd::string, xtd::string > >, xtd::collections::generic::list< xtd::drawing::color >, xtd::collections::generic::list< xtd::drawing::drawing_2d::gradient_stop >, xtd::collections::generic::list< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::list< xtd::forms::style_sheets::shadow >, xtd::collections::generic::list< xtd::ref< xtd::forms::form > >, xtd::collections::generic::list< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::list< xtd::string >, xtd::collections::generic::list< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::list< xtd::tunit::test >, xtd::collections::generic::list< xtd::usize >, xtd::collections::generic::list< xtd_library >, xtd::collections::generic::ordered_dictionary< key_t, value_t, allocator_t >, xtd::collections::generic::ordered_dictionary< xtd::any_object, xtd::any_object >, xtd::collections::generic::queue< type_t, container_t >, xtd::collections::generic::queue< value_type >, xtd::collections::generic::queue< xtd::any_object >, xtd::collections::generic::stack< type_t, container_t >, xtd::collections::generic::stack< xtd::any_object >, xtd::collections::object_model::read_only_collection< type_t >, xtd::collections::object_model::read_only_collection< value_type >, xtd::forms::layout::arranged_element_collection< type_t, sorter_t >, xtd::forms::layout::arranged_element_collection< drawing::image >, xtd::forms::layout::arranged_element_collection< item >, xtd::forms::layout::arranged_element_collection< item, item::sorter >, xtd::forms::layout::arranged_element_collection< status_bar_panel_ref >, xtd::forms::layout::arranged_element_collection< tab_page_ref >, xtd::forms::layout::arranged_element_collection< tool_bar_button_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::control_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::link_label::link >, xtd::forms::layout::arranged_element_collection< xtd::forms::menu_item_ref >, xtd::forms::layout::arranged_element_collection< xtd::forms::message_notifier_button_ref >, and xtd::forms::layout::arranged_element_collection< xtd::string >.

◆ remove()

template<typename type_t>
virtual auto xtd::collections::generic::icollection< type_t >::remove ( const type_t & item) -> bool
pure virtual

Removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.

Parameters
itemThe object to remove from the xtd::collections::generic::icollection <type_t>.
Returns
true if item was successfully removed from the xtd::collections::generic::icollection <type_t>; otherwise, false. This method also returns false if item is not found in the original xtd::collections::generic::icollection <type_t>.
Exceptions
xtd::not_supported_exceptionThe xtd::collections::generic::icollection <type_t> is read-only.
Remarks
Implementations can vary in how they determine equality of objects; for example, xtd::collections::generic::list <type_t> uses xtd::collections::generic::compoarer <type_t>::default_comparer, whereas, xtd::collections::generic::dictionary <key_t, value_t> allows the user to specify the xtd::collections::generic::icompoarer <type_t> implementation to use for comparing keys.
In collections of contiguous elements, such as lists, the elements that follow the removed element move up to occupy the vacated spot. If the collection is indexed, the indexes of the elements that are moved are also updated. This behavior does not apply to collections where elements are conceptually grouped into buckets, such as a hash table.

Implemented in xtd::collections::generic::idictionary< key_t, value_t >, xtd::collections::generic::ilist< type_t >, xtd::collections::generic::ilist< byte >, xtd::collections::generic::ilist< int32 >, xtd::collections::generic::ilist< item_t >, xtd::collections::generic::ilist< list_type_t >, xtd::collections::generic::ilist< value_type >, xtd::collections::generic::ilist< xtd::any_object >, xtd::collections::generic::ilist< xtd::array< xtd::byte > >, xtd::collections::generic::ilist< xtd::basic_string< char > >, xtd::collections::generic::ilist< xtd::byte >, xtd::collections::generic::ilist< xtd::drawing::color >, xtd::collections::generic::ilist< xtd::drawing::imaging::encoder_parameter >, xtd::collections::generic::ilist< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::ilist< xtd::net::ip_address >, xtd::collections::generic::ilist< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::ilist< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::ilist< xtd::time_zone_info::adjustment_rule >, xtd::collections::generic::ilist< xtd::uint16 >, xtd::collections::generic::linked_list< type_t, allocator_t >, xtd::collections::generic::linked_list< type_t >, xtd::collections::generic::linked_list< value_type >, xtd::collections::generic::list< type_t, allocator_t >, xtd::collections::generic::list< byte >, xtd::collections::generic::list< int32 >, xtd::collections::generic::list< value_type >, xtd::collections::generic::list< xtd::any_object >, xtd::collections::generic::list< xtd::byte >, xtd::collections::generic::list< xtd::drawing::color >, xtd::collections::generic::list< xtd::forms::layout::arranged_element_collection::value_type >, xtd::collections::generic::list< xtd::sptr< xtd::diagnostics::trace_listener > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::control > >, xtd::collections::generic::list< xtd::sptr< xtd::forms::menu_item > >, xtd::collections::generic::list< xtd::time_zone_info::adjustment_rule >, and xtd::forms::layout::arranged_element_collection< type_t, sorter_t >.


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