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 = generic::icollection< type_t >::iterator |
Represents the iterator of list value type. | |
using | const_iterator = 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 | |
Public Types inherited from xtd::collections::generic::ilist< type_t > | |
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. | |
Public Types inherited from xtd::collections::generic::icollection< type_t > | |
using | iterator = typename ienumerable< type_t >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator = typename ienumerable< type_t >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
Public Types inherited from xtd::collections::generic::ienumerable< type_t > | |
using | iterator = typename enumerable_iterators< type_t, ienumerable< type_t > >::iterator |
Represents the iterator of xtd::collections::generic::ienumerable value type. | |
using | const_iterator = typename enumerable_iterators< type_t, ienumerable< type_t > >::const_iterator |
Represents the const iterator of xtd::collections::generic::ienumerable value type. | |
Public Types inherited from xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > > | |
using | const_iterator = const iterator |
Represents the const iterator of enumarable value type. | |
Static Public Attributes inherited from xtd::collections::generic::ilist< type_t > | |
static constexpr xtd::size | npos |
This is a special value equal to the maximum value representable by the type xtd::size. | |
Public Member Functions inherited from xtd::object | |
object ()=default | |
Create a new instance of the ultimate base class object. | |
virtual bool | equals (const object &obj) const noexcept |
Determines whether the specified object is equal to the current object. | |
virtual size_t | 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<typename 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. | |
Public Member Functions inherited from xtd::collections::generic::ilist< type_t > | |
Public Member Functions inherited from xtd::collections::generic::icollection< type_t > | |
Public Member Functions inherited from xtd::collections::generic::ienumerable< type_t > | |
Public Member Functions inherited from xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > > | |
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. | |
Static Public Member Functions inherited from xtd::object | |
template<typename object_a_t , typename 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<typename object_a_t , typename 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. | |