xtd 0.2.0
Loading...
Searching...
No Matches
xtd::basic_array< type_t, allocator_t > Class Template Reference
Inheritance diagram for xtd::basic_array< type_t, allocator_t >:
xtd::array_abstract_object xtd::collections::generic::ilist< type_t > xtd::iequatable< type_t > xtd::abstract_object xtd::collections::generic::icollection< type_t > xtd::interface xtd::equality_operators< type_t, iequatable< type_t > > xtd::object xtd::collections::generic::ienumerable< type_t > xtd::interface xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > > xtd::array< value_type >

Definition

template<typename type_t, typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
class xtd::basic_array< type_t, allocator_t >

Base object that represent array.

Definition
template<typename type_t, typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
class basic_array : public xtd::array_object, public xtd::collections::generic::ilist<type_t>, public xtd::iequatable<basic_array<type_t, allocator_t>>;
Base object that represent array.
Definition basic_array.h:27
Represents a collection of objects that can be individually accessed by index.
Definition ilist.h:41
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
std::type_info type
Stores information about a type.
Definition type.h:23
Header
#include <xtd/array>
Namespace
xtd
Library
xtd.core

Public Aliases

using value_type = type_t
 Represents the array value type.
 
using allocator_type = xtd::collections::generic::helpers::allocator< typename std::conditional< std::is_same< bool, value_type >::value, xtd::byte, value_type >::type >
 Represents the array allocator type.
 
using base_type = std::vector< typename std::conditional< std::is_same< bool, value_type >::value, xtd::byte, value_type >::type, allocator_type >
 Represents the array base type.
 
using size_type = xtd::size
 Represents the array size type (usually xtd::size).
 
using difference_type = xtd::ptrdiff
 Represents the array difference type (usually xtd::ptrdiff).
 
using reference = value_type &
 Represents the reference of array value type.
 
using const_reference = const value_type &
 Represents the const reference of array value type.
 
using pointer = value_type *
 Represents the pointer of array value type.
 
using const_pointer = const value_type *
 Represents the const pointer of array value type.
 
using iterator = typename xtd::collections::generic::ilist< type_t >::iterator
 Represents the iterator of array value type.
 
using const_iterator = typename xtd::collections::generic::ilist< type_t >::const_iterator
 Represents the const iterator of array value type.
 
using reverse_iterator = typename base_type::reverse_iterator
 Represents the reverse iterator of array value type.
 
using const_reverse_iterator = typename base_type::const_reverse_iterator
 Represents the const reverse iterator of array value type.
 

Public Fields

static constexpr size_type npos
 This is a special value equal to the maximum value representable by the type xtd::size.
 

Public Properties

virtual reference back ()
 Returns a reference to the last element in the container.
 
virtual const_reference back () const
 Returns a reference to the last element in the container.
 
const_iterator begin () const noexcept override
 Returns an iterator to the first element of the enumarable.
 
iterator begin () noexcept override
 Returns an iterator to the first element of the enumarable.
 
const_iterator cbegin () const noexcept override
 Returns an iterator to the first element of the enumarable.
 
const_iterator cend () const noexcept override
 Returns an iterator to the element following the last element of the enumarable.
 
size_type count () const noexcept override
 Gets the number of elements contained in the xtd::array <type_t>.
 
virtual const_reverse_iterator crbegin () const noexcept
 Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to xtd::array::rend().
 
virtual const_reverse_iterator crend () const noexcept
 Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.
 
virtual pointer data () noexcept
 Returns pointer to the underlying array serving as element storage.
 
virtual const_pointer data () const noexcept
 Returns pointer to the underlying array serving as element storage.
 
virtual bool empty () const noexcept
 Checks if the container has no elements, i.e. whether xtd::array::begin() == xtd::array::end().
 
const_iterator end () const noexcept override
 Returns an iterator to the element following the last element of the enumarable.
 
iterator end () noexcept override
 Returns an iterator to the element following the last element of the enumarable.
 
virtual reference front ()
 Returns a reference to the first element in the container.
 
virtual const_reference front () const
 Returns a reference to the first element in the container.
 
bool is_fixed_size () const noexcept override
 Gets a value indicating whether the xtd::collections::generic::ilist <type_t> has a fixed size.
 
bool is_read_only () const noexcept override
 Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
 
bool is_synchronized () const noexcept override
 Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe).
 
virtual const base_typeitems () const noexcept
 Returns the underlying base type items.
 
virtual base_typeitems () noexcept
 Returns the underlying base type items.
 
virtual size_type length () const noexcept
 Gets a size that represents the total number of elements in all the dimensions of the array.
 
virtual xtd::int64 long_length ()
 Gets a 64-bit integer that represents the total number of elements in all the dimensions of the array.
 
virtual size_type max_size () const noexcept
 Returns the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. std::distance(xtd::array::begin(), xtd::array::end()) for the largest container.
 
virtual size_type rank () const noexcept
 Gets the rank (number of dimensions) of the array.
 
virtual reverse_iterator rbegin () noexcept
 Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to xtd::array::rend().
 
virtual const_reverse_iterator rbegin () const noexcept
 Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to xtd::array::rend().
 
virtual reverse_iterator rend () noexcept
 Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.
 
virtual const_reverse_iterator rend () const noexcept
 Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.
 
virtual size_type size () const noexcept
 Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(), xtd::array::end()).
 
const xtd::objectsync_root () const noexcept override
 Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.
 

Public Methods

virtual reference at (size_type index)
 Returns a reference to the element at specified location pos, with bounds checking.
 
virtual const_reference at (size_type index) const
 Returns a reference to the element at specified location pos, with bounds checking.
 
constexpr bool contains (const type_t &value) const noexcept override
 Determines whether an element is in the array.
 
void copy_to (xtd::array< type_t > &array, size_type index) const override
 Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.
 
void copy_to (xtd::array< type_t > &array, xtd::int64 index) const
 Copies all the elements of the current one-dimensional array to the specified one-dimensional array starting at the specified destination array index. The index is specified as a 64-bit integer.
 
bool equals (const object &obj) const noexcept override
 Determines whether the specified object is equal to the current object.
 
bool equals (const basic_array &rhs) const noexcept override
 
virtual void fill (const value_type &value) noexcept
 Assigns the value to all elements in the container.
 
xtd::collections::generic::enumerator< value_typeget_enumerator () const noexcept override
 Returns an enumerator that iterates through a collection.
 
constexpr size_type get_length (size_type dimension) const
 Gets the total number of elements in all the dimensions of the array.
 
constexpr xtd::int64 get_long_length (size_type dimension) const
 Gets a 64-bit integer that represents the total number of elements in all the dimensions of the array.
 
constexpr size_type get_lower_bound (size_type dimension) const
 Gets the lower bound of the specified dimension in the array.
 
constexpr size_type get_upper_bound (size_type dimension) const
 Gets the upper bound of the specified dimension in the array.
 
const value_typeget_value (const xtd::array< size_type > &indexes) const
 Gets the value at the specified position in the multidimensional array. The indexes are specified as 32-bit integers array.
 
size_type index_of (const type_t &value) const noexcept override
 Determines the index of a specific item in the xtd::array <type_t>.
 
void resize (size_type new_size)
 Resizes the container to contain count elements, does nothing if count == size(). @param new_size The new size of the container. @exception xtd::argument_out_of_range_exception Ifnew_sizeis outside greather than xtd::array::max_size. @remarks If the current size is greater thancount, the container is reduced to its firstcountelements. @remarks If the current size is less thancount`, additional default-inserted elements are appended.
 
void resize (size_type new_size, value_type value)
 Resizes the container to contain count elements, does nothing if count == size(). @param new_size The new size of the container. @param value The value to initialize the new elements with. @exception xtd::argument_out_of_range_exception Ifnew_sizeis outside greather than xtd::array::max_size. @remarks If the current size is greater thancount, the container is reduced to its firstcountelements. @remarks If the current size is less thancount`, additional default-inserted elements are appended.
 
void set_value (const type_t &value, const xtd::array< size_type > &indexes)
 Sets a value to the element at the specified position in the multidimensional array.
 
virtual void swap (basic_array &other) noexcept
 Exchanges the contents and capacity of the container with those of other. Does not invoke any move, copy, or swap operations on individual elements.
 
xtd::string to_string () const noexcept override
 Returns a xtd::string that represents the current object.
 

Public Operators

basic_arrayoperator= (const basic_array &other)
 Copy assignment operator. Replaces the contents with a copy of the contents of other.
 
basic_arrayoperator= (basic_array &&other) noexcept=default
 Move assignment operator. Replaces the contents with those of other using move semantics (i.e. the data in other is moved from other into this container). other is in a valid but unspecified state afterwards.
 
basic_arrayoperator= (std::initializer_list< type_t > &items)
 Replaces the contents with those identified by initializer list ilist.
 
const_reference operator[] (size_type index) const override
 Returns a reference to the element at specified location index.
 
reference operator[] (size_type index) override
 Returns a reference to the element at specified location index.
 
 operator const base_type & () const noexcept
 Returns a reference to the underlying base type.
 
 operator base_type & () noexcept
 Returns a reference to the underlying base type.
 
type_t & operator() (const xtd::array< size_type > &indexes)
 Gets the value at the specified position in the multidimensional array. The indexes are specified as a 32-bit integer array.
 
const type_t & operator() (const xtd::array< size_type > &indexes) const
 Gets the value at the specified position in the multidimensional array. The indexes are specified as a 32-bit integer array.
 

Public Static Methods

static size_type index_of (const basic_array &array, const value_type &value) noexcept
 Determines the index of a specific item in the array specified.
 
static size_type index_of (const basic_array &array, const value_type &value, size_type index)
 Determines the index of a specific item in the array specified.
 
static size_type index_of (const basic_array &array, const value_type &value, size_type index, size_type count)
 Determines the index of a specific item in the array specified.
 
static void reverse (basic_array &array) noexcept
 Reverses the order of the elements in the entire xtd::basic_array.
 
static void reverse (basic_array &array, size_type index, size_type count)
 Reverses the order of the elements in the specified range.
 

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 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.
 
- 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 > >
- Public Member Functions inherited from xtd::iequatable< type_t >
virtual bool equals (const type_t &) const noexcept=0
 Indicates whether the current object is equal to another object of the same type.
 
- 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.
 
- Protected Member Functions inherited from xtd::abstract_object
 abstract_object ()=default
 Initializes a new instance of the xtd::abstract_object class.
 

Member Typedef Documentation

◆ value_type

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::value_type = type_t

Represents the array value type.

◆ allocator_type

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::allocator_type = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, value_type>::value, xtd::byte, value_type>::type>

Represents the array allocator type.

◆ base_type

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::base_type = std::vector<typename std::conditional<std::is_same<bool, value_type>::value, xtd::byte, value_type>::type, allocator_type>

Represents the array base type.

◆ size_type

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::size_type = xtd::size

Represents the array size type (usually xtd::size).

◆ difference_type

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::difference_type = xtd::ptrdiff

Represents the array difference type (usually xtd::ptrdiff).

◆ reference

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::reference = value_type&

Represents the reference of array value type.

◆ const_reference

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::const_reference = const value_type&

Represents the const reference of array value type.

◆ pointer

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::pointer = value_type*

Represents the pointer of array value type.

◆ const_pointer

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::const_pointer = const value_type*

Represents the const pointer of array value type.

◆ iterator

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::iterator = typename xtd::collections::generic::ilist<type_t>::iterator

Represents the iterator of array value type.

◆ const_iterator

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::const_iterator = typename xtd::collections::generic::ilist<type_t>::const_iterator

Represents the const iterator of array value type.

◆ reverse_iterator

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::reverse_iterator = typename base_type::reverse_iterator

Represents the reverse iterator of array value type.

◆ const_reverse_iterator

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
using xtd::basic_array< type_t, allocator_t >::const_reverse_iterator = typename base_type::const_reverse_iterator

Represents the const reverse iterator of array value type.

Member Function Documentation

◆ back() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual reference xtd::basic_array< type_t, allocator_t >::back ( )
inlinevirtual

Returns a reference to the last element in the container.

Returns
Reference to the first element.
Remarks
Calling front on an empty container causes undefined behavior.

◆ back() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const_reference xtd::basic_array< type_t, allocator_t >::back ( ) const
inlinevirtual

Returns a reference to the last element in the container.

Returns
Reference to the first element.
Remarks
Calling front on an empty container causes undefined behavior.

◆ begin() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
const_iterator xtd::basic_array< type_t, allocator_t >::begin ( ) const
inlineoverridevirtualnoexcept

Returns an iterator to the first element of the enumarable.

Returns
Iterator to the first element.

Reimplemented from xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > >.

◆ begin() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
iterator xtd::basic_array< type_t, allocator_t >::begin ( )
inlineoverridevirtualnoexcept

Returns an iterator to the first element of the enumarable.

Returns
Iterator to the first element.

Reimplemented from xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > >.

◆ cbegin()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
const_iterator xtd::basic_array< type_t, allocator_t >::cbegin ( ) const
inlineoverridevirtualnoexcept

Returns an iterator to the first element of the enumarable.

Returns
Iterator to the first element.

Reimplemented from xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > >.

◆ cend()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
const_iterator xtd::basic_array< type_t, allocator_t >::cend ( ) const
inlineoverridevirtualnoexcept

Returns an iterator to the element following the last element of the enumarable.

Returns
Iterator to the element following the last element.

Reimplemented from xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > >.

◆ count()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
size_type xtd::basic_array< type_t, allocator_t >::count ( ) const
inlineoverridevirtualnoexcept

Gets the number of elements contained in the xtd::array <type_t>.

Returns
The number of elements contained in the xtd::array <type_t>.
Remarks
Retrieving the value of this property is an O(1) operation; setting the property is an O(n) operation, where n is the new capacity.

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

◆ crbegin()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const_reverse_iterator xtd::basic_array< type_t, allocator_t >::crbegin ( ) const
inlinevirtualnoexcept

Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to xtd::array::rend().

Returns
Reverse iterator to the first element.
Remarks
If the vector is empty, the returned iterator will be equal to xtd::array::rend().

◆ crend()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const_reverse_iterator xtd::basic_array< type_t, allocator_t >::crend ( ) const
inlinevirtualnoexcept

Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.

Returns
Reverse iterator to the element following the last element.
Remarks
This element acts as a placeholder; attempting to access it results in undefined behavior.

◆ data() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual pointer xtd::basic_array< type_t, allocator_t >::data ( )
inlinevirtualnoexcept

Returns pointer to the underlying array serving as element storage.

Returns
Pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal to the address of the first element.
Remarks
The pointer is such that range [xtd::array::data(), xtd::array::data() + xtd::array::size()) is always a valid range, even if the container is empty (xtd::array::data() is not dereferenceable in that case).

◆ data() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const_pointer xtd::basic_array< type_t, allocator_t >::data ( ) const
inlinevirtualnoexcept

Returns pointer to the underlying array serving as element storage.

Returns
Pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal to the address of the first element.
Remarks
The pointer is such that range [xtd::array::data(), xtd::array::data() + xtd::array::size()) is always a valid range, even if the container is empty (xtd::array::data() is not dereferenceable in that case).

◆ empty()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual bool xtd::basic_array< type_t, allocator_t >::empty ( ) const
inlinevirtualnoexcept

Checks if the container has no elements, i.e. whether xtd::array::begin() == xtd::array::end().

Returns
true if the container is empty, false otherwise.

◆ end() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
const_iterator xtd::basic_array< type_t, allocator_t >::end ( ) const
inlineoverridevirtualnoexcept

Returns an iterator to the element following the last element of the enumarable.

Returns
Iterator to the element following the last element.

Reimplemented from xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > >.

◆ end() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
iterator xtd::basic_array< type_t, allocator_t >::end ( )
inlineoverridevirtualnoexcept

Returns an iterator to the element following the last element of the enumarable.

Returns
Iterator to the element following the last element.

Reimplemented from xtd::collections::generic::enumerable_iterators< type_t, ienumerable< type_t > >.

◆ front() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual reference xtd::basic_array< type_t, allocator_t >::front ( )
inlinevirtual

Returns a reference to the first element in the container.

Returns
Reference to the first element.
Remarks
Calling front on an empty container causes undefined behavior.

◆ front() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const_reference xtd::basic_array< type_t, allocator_t >::front ( ) const
inlinevirtual

Returns a reference to the first element in the container.

Returns
Reference to the first element.
Remarks
Calling front on an empty container causes undefined behavior.

◆ is_fixed_size()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
bool xtd::basic_array< type_t, allocator_t >::is_fixed_size ( ) const
inlineoverridevirtualnoexcept

Gets a value indicating whether the xtd::collections::generic::ilist <type_t> has a fixed size.

Returns
true if the xtd::collections::generic::ilist <type_t> has a fixed size; otherwise, false.
Remarks
A collection with a fixed size does not allow the addition or removal of elements after the collection is created, but it allows the modification of existing elements.

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

◆ is_read_only()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
bool xtd::basic_array< type_t, allocator_t >::is_read_only ( ) const
inlineoverridevirtualnoexcept

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

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

◆ is_synchronized()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
bool xtd::basic_array< type_t, allocator_t >::is_synchronized ( ) const
inlineoverridevirtualnoexcept

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

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

◆ items() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const base_type & xtd::basic_array< type_t, allocator_t >::items ( ) const
inlinevirtualnoexcept

Returns the underlying base type items.

Returns
The underlying base type items.

◆ items() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual base_type & xtd::basic_array< type_t, allocator_t >::items ( )
inlinevirtualnoexcept

Returns the underlying base type items.

Returns
The underlying base type items.

◆ length()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual size_type xtd::basic_array< type_t, allocator_t >::length ( ) const
inlinevirtualnoexcept

Gets a size that represents the total number of elements in all the dimensions of the array.

Returns
A size that represents the total number of elements in all the dimensions of the array; zero if there are no elements in the array.
Remarks
Retrieving the value of this property is an O(1) operation.
Examples
The following code example demonstrates methods to get the length of an array.

◆ long_length()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual xtd::int64 xtd::basic_array< type_t, allocator_t >::long_length ( )
inlinevirtual

Gets a 64-bit integer that represents the total number of elements in all the dimensions of the array.

Returns
int64 A 64-bit integer that represents the total number of elements in all the dimensions of the array; zero if there are no elements in the array.
Remarks
Retrieving the value of this property is an O(1) operation.

◆ max_size()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual size_type xtd::basic_array< type_t, allocator_t >::max_size ( ) const
inlinevirtualnoexcept

Returns the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. std::distance(xtd::array::begin(), xtd::array::end()) for the largest container.

Returns
Maximum number of elements.

◆ rank()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual size_type xtd::basic_array< type_t, allocator_t >::rank ( ) const
inlinevirtualnoexcept

Gets the rank (number of dimensions) of the array.

Returns
The rank (number of dimensions) of the array.
Examples
The following code example demonstrates methods to get the rank of an array.

Reimplemented in xtd::array< type_t, rank_, allocator_t >, xtd::array< value_type >, xtd::array< type_t, 1, allocator_t >, xtd::array< type_t, 2, allocator_t >, and xtd::array< type_t, 3, allocator_t >.

◆ rbegin() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual reverse_iterator xtd::basic_array< type_t, allocator_t >::rbegin ( )
inlinevirtualnoexcept

Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to xtd::array::rend().

Returns
Reverse iterator to the first element.
Remarks
If the vector is empty, the returned iterator will be equal to xtd::array::rend().

◆ rbegin() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const_reverse_iterator xtd::basic_array< type_t, allocator_t >::rbegin ( ) const
inlinevirtualnoexcept

Returns a reverse iterator to the first element of the reversed vector. It corresponds to the last element of the non-reversed vector. If the vector is empty, the returned iterator is equal to xtd::array::rend().

Returns
Reverse iterator to the first element.
Remarks
If the vector is empty, the returned iterator will be equal to xtd::array::rend().

◆ rend() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual reverse_iterator xtd::basic_array< type_t, allocator_t >::rend ( )
inlinevirtualnoexcept

Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.

Returns
Reverse iterator to the element following the last element.
Remarks
This element acts as a placeholder; attempting to access it results in undefined behavior.

◆ rend() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const_reverse_iterator xtd::basic_array< type_t, allocator_t >::rend ( ) const
inlinevirtualnoexcept

Returns a reverse iterator to the element following the last element of the reversed vector. It corresponds to the element preceding the first element of the non-reversed vector. This element acts as a placeholder, attempting to access it results in undefined behavior.

Returns
Reverse iterator to the element following the last element.
Remarks
This element acts as a placeholder; attempting to access it results in undefined behavior.

◆ size()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual size_type xtd::basic_array< type_t, allocator_t >::size ( ) const
inlinevirtualnoexcept

Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(), xtd::array::end()).

Returns
The number of elements in the container.

◆ sync_root()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
const xtd::object & xtd::basic_array< type_t, allocator_t >::sync_root ( ) const
inlineoverridevirtualnoexcept

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 (auto item : my_collection) {
// Insert your code here.
}
}
virtual const xtd::object & sync_root() const noexcept=0
Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollecti...
Defines the base class for predefined exceptions in the xtd namespace.
Definition exception.h:28
Provides a mechanism that synchronizes access to objects with xtd::threading::monitor.
Definition lock_guard.h:32
bool is(std::any value)
Checks if the result of an expression is compatible with a given type.
Definition is.h:365
@ other
The operating system is other.
@ a
The A key.

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

◆ at() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual reference xtd::basic_array< type_t, allocator_t >::at ( size_type  index)
inlinevirtual

Returns a reference to the element at specified location pos, with bounds checking.

Parameters
indexThe position of the element to return.
Returns
Reference to the requested element.
Exceptions
xtd::index_out_of_range_exceptionIf `index` is not within the range of the container.

◆ at() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual const_reference xtd::basic_array< type_t, allocator_t >::at ( size_type  index) const
inlinevirtual

Returns a reference to the element at specified location pos, with bounds checking.

Parameters
indexThe position of the element to return.
Returns
Reference to the requested element.
Exceptions
xtd::index_out_of_range_exceptionIf `index` is not within the range of the container.

◆ contains()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
constexpr bool xtd::basic_array< type_t, allocator_t >::contains ( const type_t &  value) const
inlineconstexproverridevirtualnoexcept

Determines whether an element is in the array.

Parameters
valueThe object to be added to the end of the array.

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

◆ copy_to() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
void xtd::basic_array< type_t, allocator_t >::copy_to ( xtd::array< type_t > &  array,
size_type  array_index 
) const
inlineoverridevirtual

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`.
Todo:
uncomment want array remamed into array.

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

◆ copy_to() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
void xtd::basic_array< type_t, allocator_t >::copy_to ( xtd::array< type_t > &  array,
xtd::int64  index 
) const
inline

Copies all the elements of the current one-dimensional array to the specified one-dimensional array starting at the specified destination array index. The index is specified as a 64-bit integer.

Parameters
arrayThe one-dimensional array that is the destination of the elements copied from the current array.
indexA 64-bit integer that represents the index in array at which copying begins.
Exceptions
xtd::argument_exception`array` is multidimensional.
xtd::argument_out_of_range_exception`index` is outside the range of valid indexes for array.

◆ equals()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
bool xtd::basic_array< type_t, allocator_t >::equals ( const object obj) const
inlineoverridevirtualnoexcept

Determines whether the specified object is equal to the current object.

Parameters
objThe object to compare with the current object.
Returns
true if the specified object is equal to the current object. otherwise, false.
Examples
The following code example compares the current instance with another object.
#include <xtd/console>
using namespace xtd;
auto main() -> int {
auto object1 = new_ptr<object>();
auto object2 = new_ptr<object>();
auto object3 = object2;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
object3 = object1;
console::write_line(object1->equals(*object3));
console::write_line(*object1 == *object3);
}
// This code produces the following output :
//
// false
// false
// true
// true
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10

Reimplemented from xtd::object.

◆ fill()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual void xtd::basic_array< type_t, allocator_t >::fill ( const value_type value)
inlinevirtualnoexcept

Assigns the value to all elements in the container.

Parameters
valueThe value to assign to the elements.

◆ get_enumerator()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
xtd::collections::generic::enumerator< value_type > xtd::basic_array< type_t, allocator_t >::get_enumerator ( ) const
inlineoverridevirtualnoexcept

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

◆ get_length()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
constexpr size_type xtd::basic_array< type_t, allocator_t >::get_length ( size_type  dimension) const
inlineconstexpr

Gets the total number of elements in all the dimensions of the array.

Parameters
dimensionA zero-based dimension of the array whose length needs to be determined.
Returns
The total number of elements in all the dimensions of the array; zero if there are no elements in the array.
Exceptions
xtd::argument_out_of_range_exception`dimension` is equal to or greater than xtd::basic_array::rank.
Examples
The following code example demonstrates methods to get the length of an array.

◆ get_long_length()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
constexpr xtd::int64 xtd::basic_array< type_t, allocator_t >::get_long_length ( size_type  dimension) const
inlineconstexpr

Gets a 64-bit integer that represents the total number of elements in all the dimensions of the array.

Parameters
dimensionA zero-based dimension of the array whose length needs to be determined.
Returns
A 64-bit integer that represents the total number of elements in all the dimensions of the array; zero if there are no elements in the array.
Exceptions
xtd::argument_out_of_range_exception`dimension` is equal to or greater than xtd::basic_array::rank.
Examples
The following code example demonstrates methods to get the length of an array.

◆ get_lower_bound()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
constexpr size_type xtd::basic_array< type_t, allocator_t >::get_lower_bound ( size_type  dimension) const
inlineconstexpr

Gets the lower bound of the specified dimension in the array.

Parameters
dimensionA zero-based dimension of the array whose lower bound needs to be determined.
Returns
The lower bound of the specified dimension in the array.
Exceptions
xtd::argument_out_of_range_exception`dimension` is equal to or greater than xtd::basic_array::rank.
Examples
The following code example uses xtd::array::get_lower_bound and xtd::array::get_upper_bound to initialize a one-dimensional array and a multidimensional array.

◆ get_upper_bound()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
constexpr size_type xtd::basic_array< type_t, allocator_t >::get_upper_bound ( size_type  dimension) const
inlineconstexpr

Gets the upper bound of the specified dimension in the array.

Parameters
dimensionA zero-based dimension of the array whose upper bound needs to be determined.
Returns
The upper bound of the specified dimension in the array.
Exceptions
xtd::argument_out_of_range_exception`dimension` is equal to or greater than xtd::basic_array::rank.
Examples
The following code example uses xtd::array::get_lower_bound and xtd::array::get_upper_bound to initialize a one-dimensional array and a multidimensional array.

◆ get_value()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
const value_type & xtd::basic_array< type_t, allocator_t >::get_value ( const xtd::array< size_type > &  indexes) const

Gets the value at the specified position in the multidimensional array. The indexes are specified as 32-bit integers array.

Parameters
indexesAn array that represents the position of the element to get.
Returns
The value at the specified position in the multidimensional array.
Exceptions
xtd::index_out_of_range_exceptionIf `indexes` is outside the range of valid indexes for the corresponding dimension of the current array.

◆ index_of() [1/4]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
size_type xtd::basic_array< type_t, allocator_t >::index_of ( const type_t &  value) const
inlineoverridevirtualnoexcept

Determines the index of a specific item in the xtd::array <type_t>.

Parameters
valueThe object to locate in the xtd::array.
Returns
The index of value if found in the array; otherwise, xtd::collections::generic::ilist::npos.

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

◆ resize() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
void xtd::basic_array< type_t, allocator_t >::resize ( size_type  new_size)
inline

Resizes the container to contain count elements, does nothing if count == size(). @param new_size The new size of the container. @exception xtd::argument_out_of_range_exception Ifnew_sizeis outside greather than xtd::array::max_size. @remarks If the current size is greater thancount, the container is reduced to its firstcountelements. @remarks If the current size is less thancount`, additional default-inserted elements are appended.

◆ resize() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
void xtd::basic_array< type_t, allocator_t >::resize ( size_type  new_size,
value_type  value 
)
inline

Resizes the container to contain count elements, does nothing if count == size(). @param new_size The new size of the container. @param value The value to initialize the new elements with. @exception xtd::argument_out_of_range_exception Ifnew_sizeis outside greather than xtd::array::max_size. @remarks If the current size is greater thancount, the container is reduced to its firstcountelements. @remarks If the current size is less thancount`, additional default-inserted elements are appended.

◆ set_value()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
void xtd::basic_array< type_t, allocator_t >::set_value ( const type_t &  value,
const xtd::array< size_type > &  indexes 
)
inline

Sets a value to the element at the specified position in the multidimensional array.

Parameters
valueThe new value for the specified element.
indexesAn array that represents the position of the element to set.
Exceptions
xtd::index_out_of_range_exceptionEither `indexes` is outside the range of valid indexes for the current array.

◆ swap()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
virtual void xtd::basic_array< type_t, allocator_t >::swap ( basic_array< type_t, allocator_t > &  other)
inlinevirtualnoexcept

Exchanges the contents and capacity of the container with those of other. Does not invoke any move, copy, or swap operations on individual elements.

Remarks
All iterators and references remain valid. The xtd::array::end() iterator is invalidated.

◆ to_string()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
xtd::string xtd::basic_array< type_t, allocator_t >::to_string ( ) const
overridevirtualnoexcept

Returns a xtd::string that represents the current object.

Returns
A string that represents the current object.
Examples
The following code example demonstrates what to_string returns.
#include <xtd/xtd>
using namespace xtd;
namespace examples {
namespace object_test {
class object1 : public object {
};
}
}
auto main() -> int {
ptr<object> obj1 = new_ptr<examples::object_test::object1>();
console::write_line(obj1->to_string());
ptr<object> obj2 = new_ptr<date_time>(1971, 1, 5, 23, 5, 0);
console::write_line(obj2->to_string());
ptr<object> obj3 = new_ptr<boolean_object>();
console::write_line(obj3->to_string());
}
// This code produces the following output :
//
// examples::object_test::object1
// Tue Jan 5 23:05:00 1971
// false
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
xtd::sptr< type_t > ptr
The xtd::ptr object is a shared pointer.
Definition ptr.h:27

Reimplemented from xtd::object.

◆ index_of() [2/4]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
static size_type xtd::basic_array< type_t, allocator_t >::index_of ( const basic_array< type_t, allocator_t > &  array,
const value_type value 
)
inlinestaticnoexcept

Determines the index of a specific item in the array specified.

Parameters
arrayThe object to locate in the array.
valueThe object to locate in the array.
Returns
int32 The index of value if found in the array; otherwise, -1.
Examples
The following code example shows how to determine the index of the first occurrence of a specified element.

◆ index_of() [3/4]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
static size_type xtd::basic_array< type_t, allocator_t >::index_of ( const basic_array< type_t, allocator_t > &  array,
const value_type value,
size_type  index 
)
inlinestatic

Determines the index of a specific item in the array specified.

Parameters
arrayThe object to locate in the array.
valueThe object to locate in the array.
indexThe zero-based starting index of the search.
Returns
int32 The index of value if found in the array; otherwise, -1.
Exceptions
xtd::argument_out_of_range_exceptionThe parameters `index` is less than 0.
Examples
The following code example shows how to determine the index of the first occurrence of a specified element.

◆ index_of() [4/4]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
static size_type xtd::basic_array< type_t, allocator_t >::index_of ( const basic_array< type_t, allocator_t > &  array,
const value_type value,
size_type  index,
size_type  count 
)
inlinestatic

Determines the index of a specific item in the array specified.

Parameters
arrayThe object to locate in the array.
valueThe object to locate in the array.
indexThe zero-based starting index of the search.
countThe number of elements in the section to search
Returns
int32 The index of value if found in the array; otherwise, -1.
Exceptions
xtd::argument_out_of_range_exceptionThe parameters `index` and `count` do not specify a valid section in the 'array'.
Examples
The following code example shows how to determine the index of the first occurrence of a specified element.

◆ reverse() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
static void xtd::basic_array< type_t, allocator_t >::reverse ( basic_array< type_t, allocator_t > &  array)
inlinestaticnoexcept

Reverses the order of the elements in the entire xtd::basic_array.

Remarks
This method uses std::reverse to reverse the order of the elements, such that the element at xtd::basic_array <type_t>[i], where i is any index within the range, moves to xtd::basic_array <type_t>[j], where j equals index plus index plus count minus i minus 1.
This method is an O(n) operation, where n is xtd::basic_array::count.

◆ reverse() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
static void xtd::basic_array< type_t, allocator_t >::reverse ( basic_array< type_t, allocator_t > &  array,
size_type  index,
size_type  count 
)
inlinestatic

Reverses the order of the elements in the specified range.

Parameters
indexThe zero-based starting index of the range to reverse.
countThe number of elements in the range to reverse.
Exceptions
xtd::argument_out_of_range_exception`index` and `count` do not denote a valid range of elements in the xtd::basic_array.
Remarks
This method uses std::reverse to reverse the order of the elements, such that the element at xtd::basic_array <type_t>[i], where i is any index within the range, moves to xtd::basic_array <type_t>[j], where j equals index plus index plus count minus i minus 1.
This method is an O(n) operation, where n is count.

◆ operator=() [1/3]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
basic_array & xtd::basic_array< type_t, allocator_t >::operator= ( const basic_array< type_t, allocator_t > &  other)
inline

Copy assignment operator. Replaces the contents with a copy of the contents of other.

Parameters
otherAnother container to use as data source.
Returns
This current instance.

◆ operator=() [2/3]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
basic_array & xtd::basic_array< type_t, allocator_t >::operator= ( basic_array< type_t, allocator_t > &&  other)
defaultnoexcept

Move assignment operator. Replaces the contents with those of other using move semantics (i.e. the data in other is moved from other into this container). other is in a valid but unspecified state afterwards.

Parameters
otherAnother base type container to use as data source.
Returns
This current instance.

◆ operator=() [3/3]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
basic_array & xtd::basic_array< type_t, allocator_t >::operator= ( std::initializer_list< type_t > &  items)
inline

Replaces the contents with those identified by initializer list ilist.

Parameters
itemsInitializer list to use as data source
Returns
This current instance.

◆ operator[]() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
const_reference xtd::basic_array< type_t, allocator_t >::operator[] ( size_type  index) const
inlineoverridevirtual

Returns a reference to the element at specified location index.

Parameters
indexThe position of the element to return.
Returns
Reference to the requested element.
Exceptions
xtd::index_out_of_range_exceptionIf pos is not within the range of the container.

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

◆ operator[]() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
reference xtd::basic_array< type_t, allocator_t >::operator[] ( size_type  index)
inlineoverridevirtual

Returns a reference to the element at specified location index.

Parameters
indexThe position of the element to return.
Returns
Reference to the requested element.
Exceptions
xtd::index_out_of_range_exceptionIf `index` is not within the range of the container.

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

◆ operator const base_type &()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
xtd::basic_array< type_t, allocator_t >::operator const base_type & ( ) const
inlinenoexcept

Returns a reference to the underlying base type.

Returns
Reference to the underlying base type.

◆ operator base_type &()

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
xtd::basic_array< type_t, allocator_t >::operator base_type & ( )
inlinenoexcept

Returns a reference to the underlying base type.

Returns
Reference to the underlying base type.

◆ operator()() [1/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
type_t & xtd::basic_array< type_t, allocator_t >::operator() ( const xtd::array< size_type > &  indexes)

Gets the value at the specified position in the multidimensional array. The indexes are specified as a 32-bit integer array.

Parameters
indexesAn array that represents the multidimension index of the array element to get.
Returns
The value at the specified position in the multidimensional array.
Exceptions
xtd::index_out_of_range_exceptionEither each index is outside the range of valid indexes for the corresponding dimension of the current array.
Examples
The following code example shows how to use operator [] to list the elements of an array.

◆ operator()() [2/2]

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
const type_t & xtd::basic_array< type_t, allocator_t >::operator() ( const xtd::array< size_type > &  indexes) const

Gets the value at the specified position in the multidimensional array. The indexes are specified as a 32-bit integer array.

Parameters
indexesAn array that represents the multidimension index of the array element to get.
Returns
The value at the specified position in the multidimensional array.
Exceptions
xtd::index_out_of_range_exceptionEither each index is outside the range of valid indexes for the corresponding dimension of the current array.
Examples
The following code example shows how to use operator [] to list the elements of an array.

Member Data Documentation

◆ npos

template<typename type_t , typename allocator_t = xtd::collections::generic::helpers::allocator<typename std::conditional<std::is_same<bool, type_t>::value, char, type_t>::type>>
constexpr size_type xtd::basic_array< type_t, allocator_t >::npos
inlinestaticconstexpr

This is a special value equal to the maximum value representable by the type xtd::size.


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