Provides the base class for a generic read-only collection.
After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
Public Aliases | |
using | value_type = type_t |
Represents the list value type. | |
using | base_type = ptr< xtd::collections::generic::ilist< value_type > > |
Represents the list base type. | |
using | size_type = xtd::size |
Represents the list size type (usually xtd::size). | |
using | difference_type = xtd::ptrdiff |
Represents the list difference type (usually xtd::ptrdiff). | |
using | reference = value_type & |
Represents the reference of list value type. | |
using | const_reference = const value_type & |
Represents the const reference of list value type. | |
using | pointer = value_type * |
Represents the pointer of list value type. | |
using | const_pointer = const value_type * |
Represents the const pointer of list value type. | |
using | iterator = typename generic::icollection< type_t >::iterator |
Represents the iterator of list value type. | |
using | const_iterator = typename generic::icollection< type_t >::const_iterator |
Represents the const iterator of list value type. | |
Public Fields | |
static constexpr xtd::size | npos |
This is a special value equal to the maximum value representable by the type xtd::size. | |
Public Constructors | |
read_only_collection (ptr< generic::ilist< value_type > > list) | |
Initializes a new instance of the xtd::collections::object_model::read_only_collection <type_t> class that is a read-only wrapper around the specified list. | |
Public Properties | |
xtd::size | count () const noexcept override |
Gets the number of elements contained in the xtd::collections::object_model::read_only_collection <type_t> instance. | |
const xtd::object & | sync_root () const noexcept override |
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>. | |
static const read_only_collection< value_type > & | empty () |
Gets an empty xtd::collections::object_model::read_only_collection <type_t>. | |
Public Methods | |
bool | contains (const type_t &item) const noexcept override |
Determines whether an element is in the xtd::collections::object_model::read_only_collection <type_t>. | |
void | copy_to (xtd::array< type_t > &array, xtd::size array_index) const override |
Copies the entire xtd::collections::object_model::read_only_collection <type_t> to a compatible one-dimensional Array, starting at the specified index of the target array. | |
generic::enumerator< type_t > | get_enumerator () const noexcept override |
Returns an enumerator that iterates through the xtd::collections::object_model::read_only_collection <type_t>. | |
xtd::size | index_of (const type_t &item) const noexcept override |
Searches for the specified object and returns the zero-based index of the first occurrence within the entire xtd::collections::object_model::read_only_collection <type_t>. | |
Public Operators | |
const_reference | operator[] (size_type index) const override |
Returns a reference to the element at specified location pos. | |
Protected Properties | |
base_type | items () noexcept |
Returns the xtd::collections::generic::ilist <type_t> that the xtd::collections::object_model::read_only_collection <type_t> wraps. | |
Additional Inherited Members | |
![]() | |
using | iterator = typename icollection< type_t >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator = typename icollection< type_t >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
![]() | |
using | value_type = typename xtd::collections::generic::ienumerable< type_t >::value_type |
Represents the xtd::collections::generic::icollection value type. | |
using | iterator = typename xtd::collections::generic::ienumerable< type_t >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator = typename xtd::collections::generic::ienumerable< type_t >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
![]() | |
using | value_type = type_t |
Represents the xtd::collections::generic::ienumerable value type. | |
using | iterator = typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator = typename xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
![]() | |
using | iterator = enumerable_iterator |
Represents the iterator of enumarable value type. | |
using | const_iterator = const enumerable_iterator |
Represents the const iterator of enumarable value type. | |
![]() | |
using | enumerable_type = ienumerable< type_t > |
Represents the ienumerable enumerable type. | |
using | source_type = type_t |
Represents the ienumerable source type. | |
using | ienumerable = typename xtd::linq::enumerable::ienumerable< type_t > |
Represents the ienumerable value type. | |
using | list = typename xtd::linq::enumerable::list< type_t > |
Represents the list value type. | |
![]() | |
static constexpr xtd::size | npos |
This is a special value equal to the maximum value representable by the type xtd::size. | |
![]() | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual xtd::size | get_hash_code () const noexcept |
Serves as a hash function for a particular type. | |
virtual type_object | get_type () const noexcept |
Gets the type of the current instance. | |
template<class object_t > | |
xtd::uptr< object_t > | memberwise_clone () const |
Creates a shallow copy of the current object. | |
virtual xtd::string | to_string () const noexcept |
Returns a xtd::string that represents the current object. | |
![]() | |
![]() | |
![]() | |
![]() | |
virtual const_iterator | begin () const |
Returns an iterator to the first element of the enumarable. | |
virtual iterator | begin () |
Returns an iterator to the first element of the enumarable. | |
virtual const_iterator | cbegin () const |
Returns an iterator to the first element of the enumarable. | |
virtual const_iterator | cend () const |
Returns an iterator to the element following the last element of the enumarable. | |
virtual const_iterator | end () const |
Returns an iterator to the element following the last element of the enumarable. | |
virtual iterator | end () |
Returns an iterator to the element following the last element of the enumarable. | |
![]() | |
type_t | aggregate (const std::function< type_t(const type_t &, const type_t &)> &func) const |
Applies an accumulator function over a sequence. | |
type_t | aggregate (const type_t &seed, const std::function< type_t(const type_t &, const type_t &)> &func) const |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value. | |
accumulate_t | aggregate (const accumulate_t &seed, const std::function< accumulate_t(const type_t &, const accumulate_t &)> &func) const |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value. | |
type_t | aggregate (const type_t &seed, const std::function< type_t(const type_t &, const type_t &)> &func, const std::function< type_t(const type_t &)> &result_selector) const |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value. | |
result_t | aggregate (const accumulate_t &seed, const std::function< accumulate_t(const type_t &, const accumulate_t &)> &func, const std::function< result_t(const accumulate_t &)> &result_selector) const |
Applies an accumulator function over a sequence. The specified seed value is used as the initial accumulator value, and the specified function is used to select the result value. | |
bool | all (const std::function< bool(const type_t &)> &predicate) const |
Determines whether all elements of a sequence satisfy a condition. | |
bool | any () const noexcept |
Determines whether a sequence contains any elements. | |
bool | any (const std::function< bool(const type_t &)> &predicate) const |
Determines whether any element of a sequence satisfies a condition. | |
const ienumerable< type_t > & | append (const type_t &element) const noexcept |
Appends a value to the end of the sequence. | |
const ienumerable< type_t > & | as_enumerable () const noexcept |
Returns the input typed as xtd::collections::generic::ienumerable <type_t>. | |
auto | average () const noexcept |
Computes the average of a sequence of source_t values. | |
const ienumerable< result_t > & | cast () const noexcept |
Casts the elements of an xtd::collections::generic::ienumerable to the specified type. | |
const ienumerable< xtd::array< type_t > > & | chunk (size_t size) const |
Splits the elements of a sequence into chunks of size at most size. | |
const ienumerable< type_t > & | concat (const ienumerable< type_t > &second) const noexcept |
Concatenates two sequences. | |
bool | contains (const type_t &value) const noexcept |
Determines whether a sequence contains a specified element by using the default equality comparer. | |
bool | contains (const type_t &value, const xtd::collections::generic::iequality_comparer< type_t > &comparer) const noexcept |
Determines whether a sequence contains a specified element by using a specified equality comparer. | |
size_t | count () const noexcept |
Returns the number of elements in current sequence. | |
size_t | count (const std::function< bool(const type_t &)> &predicate) const noexcept |
Returns a number that represents how many elements in the specified sequence satisfy a condition. | |
xtd::size | count (const type_t &value) const noexcept |
Returns the number of elements with the specified value. | |
const ienumerable< key_value_pair< key_t, xtd::size > > & | count_by (const std::function< key_t(const type_t &)> &key_selector) const noexcept |
Returns the count of elements in the current sequence grouped by key. | |
const ienumerable< key_value_pair< key_t, xtd::size > > & | count_by (const std::function< key_t(const type_t &)> &key_selector, const iequality_comparer< key_t > &key_comparer) const noexcept |
Returns the count of elements in the current sequence grouped by key. | |
const ienumerable< type_t > & | default_if_empty () const noexcept |
Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty. | |
const ienumerable< type_t > & | default_if_empty (const type_t &default_value) const noexcept |
Returns the elements of the specified sequence or the specified value in a singleton collection if the current sequence is empty. | |
type_t | first_or_default (const std::function< bool(const type_t &)> &predicate, const type_t &default_value) const noexcept |
Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found. | |
type_t | first_or_default (const std::function< bool(const type_t &)> &predicate) const noexcept |
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. | |
type_t | first_or_default (const type_t default_value) const noexcept |
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. | |
type_t | first_or_default () const noexcept |
Returns the first element of the sequence that satisfies a condition or a default value if no such element is found. | |
const ienumerable< result_t > & | select (const std::function< result_t(const type_t &)> &selector) const |
Projects each element of a sequence into a new form. | |
const ienumerable< type_t > & | select (const std::function< type_t(const type_t &)> &selector) const |
Projects each element of a sequence into a new form. | |
const ienumerable< result_t > & | select (const std::function< result_t(const type_t &, size_t index)> &selector) const |
Projects each element of a sequence into a new form by incorporating the element's index. | |
const ienumerable< type_t > & | select (const std::function< type_t(const type_t &, size_t index)> &selector) const |
Projects each element of a sequence into a new form by incorporating the element's index. | |
const list< type_t > & | to_list () const noexcept |
Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>. | |
const ienumerable< type_t > & | where (const std::function< bool(const type_t &)> &predicate) const |
Filters a sequence of values based on a predicate. | |
const ienumerable< type_t > & | where (const std::function< bool(const type_t &, size_t)> &predicate) const |
Filters a sequence of values based on a predicate. Each element's index is used in the logic of the predicate function. | |
![]() | |
virtual icollection< type_t > & | operator<< (const type_t &item) |
The shift left operator adds an item to the xtd::collections::generic::icollection <type_t>. | |
virtual icollection< type_t > & | operator>> (const type_t &item) |
The shift right operator removes tthe first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>. | |
![]() | |
template<class object_a_t , class object_b_t > | |
static bool | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are considered equal. | |
template<class object_a_t , class object_b_t > | |
static bool | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept |
Determines whether the specified object instances are the same instance. | |
![]() | |
static target_collection_t::const_iterator | to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept |
Converts source iterator to target iterator. | |
static target_collection_t::iterator | to_iterator (typename source_collection_t::iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept |
Converts source iterator to target iterator. | |
static target_collection_t::const_iterator | to_iterator (typename source_collection_t::const_iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept |
Converts source iterator to target iterator. | |
static target_collection_t::iterator | to_iterator (typename source_collection_t::iterator &value, source_collection_t &source_collection, target_collection_t &target_collection) noexcept |
Converts source iterator to target iterator. | |
using xtd::collections::object_model::read_only_collection< type_t >::value_type = type_t |
Represents the list value type.
using xtd::collections::object_model::read_only_collection< type_t >::base_type = ptr<xtd::collections::generic::ilist<value_type> > |
Represents the list base type.
using xtd::collections::object_model::read_only_collection< type_t >::size_type = xtd::size |
Represents the list size type (usually xtd::size).
using xtd::collections::object_model::read_only_collection< type_t >::difference_type = xtd::ptrdiff |
Represents the list difference type (usually xtd::ptrdiff).
using xtd::collections::object_model::read_only_collection< type_t >::reference = value_type& |
Represents the reference of list value type.
using xtd::collections::object_model::read_only_collection< type_t >::const_reference = const value_type& |
Represents the const reference of list value type.
using xtd::collections::object_model::read_only_collection< type_t >::pointer = value_type* |
Represents the pointer of list value type.
using xtd::collections::object_model::read_only_collection< type_t >::const_pointer = const value_type* |
Represents the const pointer of list value type.
using xtd::collections::object_model::read_only_collection< type_t >::iterator = typename generic::icollection<type_t>::iterator |
Represents the iterator of list value type.
using xtd::collections::object_model::read_only_collection< type_t >::const_iterator = typename generic::icollection<type_t>::const_iterator |
Represents the const iterator of list value type.
|
inlineexplicit |
Initializes a new instance of the xtd::collections::object_model::read_only_collection <type_t> class that is a read-only wrapper around the specified list.
After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
list
, expose list
only through this wrapper.
|
inlineoverridevirtualnoexcept |
Gets the number of elements contained in the xtd::collections::object_model::read_only_collection <type_t> instance.
After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
Implements xtd::collections::generic::icollection< type_t >.
|
inlinestatic |
Gets an empty xtd::collections::object_model::read_only_collection <type_t>.
|
inlineoverridevirtualnoexcept |
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.
sync_root
property. 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. synchronized
method on a collection, the expected usage for the xtd::collections::generic::icollection::sync_root looks as follows: Implements xtd::collections::generic::icollection< type_t >.
|
inlineoverridevirtualnoexcept |
Determines whether an element is in the xtd::collections::object_model::read_only_collection <type_t>.
item | The object to locate in the xtd::collections::object_model::read_only_collection <type_t>. The value can be null for reference types. |
true
if value is found in the xtd::collections::object_model::read_only_collection <type_t>; otherwise, false
. After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
Implements xtd::collections::generic::icollection< type_t >.
|
inlineoverridevirtual |
Copies the entire xtd::collections::object_model::read_only_collection <type_t> to a compatible one-dimensional Array, starting at the specified index of the target array.
array | The one-dimensional xtd::array that is the destination of the elements copied from xtd::collections::object_model::read_only_collection <type_t>. The xtd::array must have zero-based indexing. |
array_index | The zero-based index in array at which copying begins. |
xtd::argument_exception | The number of elements in the source xtd::collections::object_model::read_only_collection <type_t> is greater than the available space from index to the end of the destination array. |
After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
Implements xtd::collections::generic::icollection< type_t >.
|
inlineoverridevirtualnoexcept |
Returns an enumerator that iterates through the xtd::collections::object_model::read_only_collection <type_t>.
After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
for each
is recommended, instead of directly manipulating the enumerator. false
. When the enumerator is at this position, subsequent calls to MoveNext also return false
. If the last call to MoveNext returned false
, Current is undefined. You cannot set xtd::collections::generic::enumerator::current to the first element of the collection again; you must create a new enumerator instance instead. Implements xtd::collections::generic::ienumerable< type_t >.
|
inlineoverridevirtualnoexcept |
Searches for the specified object and returns the zero-based index of the first occurrence within the entire xtd::collections::object_model::read_only_collection <type_t>.
item | The object to locate in the xtd::collections::object_model::read_only_collection <type_t>. |
After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
Implements xtd::collections::generic::ilist< type_t >.
|
inlineoverridevirtual |
Returns a reference to the element at specified location pos.
index | The position of the element to return. |
After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
my_collection[index]
. Implements xtd::collections::generic::ilist< type_t >.
|
inlineprotectednoexcept |
Returns the xtd::collections::generic::ilist <type_t> that the xtd::collections::object_model::read_only_collection <type_t> wraps.
After demonstrating the xtd::collections::object_model::read_only_collection::count, xtd::collections::object_model::read_only_collection::contains, xtd::collections::object_model::read_only_collection:: opertor [], and xtd::collections::generic::ilist::index_of members, the code example shows that the xtd::collections::object_model::read_only_collection <type_t> is just a wrapper for the original xtd::collections::generic::list <type_t> by adding a new item to the xtd::collections::generic::list <type_t> and displaying the contents of the xtd::collections::object_model::read_only_collection <type_t>.
Finally, the code example creates an array larger than the collection and uses the xtd::collections::object_model::read_only_collection::copy_to method to insert the elements of the collection into the middle of the array.
|
inlinestaticconstexpr |
This is a special value equal to the maximum value representable by the type xtd::size.