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

Definition

template<typename type_t, typename allocator_t>
class xtd::array_< type_t, 1, allocator_t >

Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays.

Definition
template<typename type_t, xtd::size rank_, typename allocator_t>
class array : public xtd::basic_array<type_t, allocator_t>;
Base object that represent array.
Definition basic_array.h:27
std::vector< type_t > array
Definition __array_definition.h:18
Header
#include <xtd/array>
Namespace
xtd
Library
xtd.core
Remarks
The xtd::array class is not part of the xtd::collections namespaces. However, it is still considered a collection because it is based on the xtd::collections::generic::ilist interface.
An element is a value in an xtd::array. The length of an xtd::array is the total number of elements it can contain. The lower bound of an v is the index of its first element. An xtd::array can have any lower bound, but it has a lower bound of zero by default. A different lower bound can be defined when creating an instance of the xtd::array class using xtd::array::create_instance. A multidimensional xtd::array can have different bounds for each dimension. An array can have a maximum of 32 dimensions.
Unlike the classes in the xtd::collections namespaces, xtd::array has a fixed capacity. To increase the capacity, you must create a new xtd::array object with the required capacity, copy the elements from the old xtd::array object to the new one, and delete the old xtd::array.
The xtd::array class implements the xtd::collections::generic::ilist, xtd::collections::generic::icollection, and xtd::collections::generic::ienumerable generic interfaces. The implementations are provided to arrays at run time, and as a result, the generic interfaces do not appear in the declaration syntax for the xtd::array class. In addition, there are no reference topics for interface members that are accessible only by casting an array to the generic interface type (explicit interface implementations). The key thing to be aware of when you cast an array to one of these interfaces is that members which add, insert, or remove elements throw xtd::not_supported_exception.
The xtd::array::copy method copies elements not only between arrays of the same type but also between standard arrays of different types; it handles type casting automatically.
Some methods, such as xtd::array::create_instance, xtd::array::copy, xtd::array::copy_to, xtd::array::get_value, and xtd::array::set_value, provide overloads that accept 64-bit integers as parameters to accommodate large capacity arrays. xtd::array::long_length and xtd::array::get_long_length return 64-bit integers indicating the length of the array.
The xtd::array is not guaranteed to be sorted. You must sort the xtd::array prior to performing operations (such as xtd::array::binary_search) that require the xtd::array to be sorted.
Examples
The following code example demonstrates different methods to create an array.
Examples
The following code example creates and initializes an Array and displays its properties and its elements.

Public Aliases

using value_type = type_t
 Represents the array value type.
 
using allocator_type = typename xtd::basic_array< type_t, allocator_t >::allocator_type
 Represents the array allocator type.
 
using base_type = typename xtd::basic_array< type_t, allocator_t >::base_type
 Represents the array base type.
 
using size_type = typename xtd::basic_array< type_t, allocator_t >::size_type
 Represents the array size type (usually xtd::size).
 
using difference_type = typename xtd::basic_array< type_t, allocator_t >::difference_type
 Represents the array difference type (usually xtd::ptrdiff).
 
using reference = typename xtd::basic_array< type_t, allocator_t >::reference
 Represents the reference of array value type.
 
using const_reference = typename xtd::basic_array< type_t, allocator_t >::const_reference
 Represents the const reference of array value type.
 
using pointer = typename xtd::basic_array< type_t, allocator_t >::pointer
 Represents the pointer of array value type.
 
using const_pointer = typename xtd::basic_array< type_t, allocator_t >::const_pointer
 Represents the const pointer of array value type.
 
using iterator = typename xtd::basic_array< type_t, allocator_t >::iterator
 Represents the iterator of array value type.
 
using const_iterator = typename xtd::basic_array< type_t, allocator_t >::const_iterator
 Represents the const iterator of array value type.
 
using reverse_iterator = typename xtd::basic_array< type_t, allocator_t >::reverse_iterator
 Represents the reverse iterator of array value type.
 
using const_reverse_iterator = typename xtd::basic_array< type_t, allocator_t >::const_reverse_iterator
 Represents the const reverse iterator of array value type.
 

Public Constructors

 array_ ()=default
 Initializes a new instance of the Array class that is empty.
 
 array_ (const array_ &array)
 Copy constructor with specified array.
 
 array_ (const array_ &&array)
 Move constructor with specified array.
 
 array_ (const base_type &array)
 Copy constructor with specified base type array.
 
 array_ (base_type &&array)
 Move constructor with specified base type array.
 
 array_ (size_type length)
 Initializes a new instance of the array class with lengths for each rank specified.
 
 array_ (std::initializer_list< type_t > items)
 Constructs the container with the contents of the specified initializer list.
 
template<xtd::size length>
 array_ (const type_t(&array)[length])
 Initializes a new instance of the array and copy array[] type_t.
 
 array_ (const type_t *array, size_type length)
 Initializes a new instance of the array and copy array[] type_t with length specified.
 
 array_ (const xtd::collections::generic::ienumerable< type_t > &enumerable)
 Initializes a new instance of the array and copy array array specified.
 
 array_ (const xtd::collections::generic::ilist< type_t > &list)
 Initializes a new instance of the array and copy array array specified.
 
template<typename iterator_t >
 array_ (iterator_t first, iterator_t last)
 Constructs the container with the contents of the range [first, last).
 

Public Properties

xtd::size rank () const noexcept override
 Gets the rank (number of dimensions) of the array.
 

Public Methods

void copy_to (xtd::array< type_t > &array, size_type index) const override
 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 32-bit integer.
 
const value_typeget_value (size_type index) const
 Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.
 
void set_value (const value_type &value, size_type index)
 Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.
 

Public Operators

array_operator= (const array_ &)=default
 
array_operator= (array_ &&)=default
 
value_typeoperator() (size_type index)
 Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.
 
const value_typeoperator() (size_type index) const
 Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.
 
value_typeoperator[] (size_type index) override
 Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.
 
const value_typeoperator[] (size_type index) const override
 Gets the element at the specified index.
 

Additional Inherited Members

- Public Types inherited from xtd::basic_array< type_t, allocator_t >
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 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::basic_array< type_t, allocator_t >
static constexpr size_type npos
 This is a special value equal to the maximum value representable by the type xtd::size.
 
- 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::basic_array< type_t, allocator_t >
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 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>.
 
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.
 
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 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< basic_array< type_t, allocator_t > >
- Static Public Member Functions inherited from xtd::basic_array< type_t, allocator_t >
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.
 
- 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 >
using xtd::array_< type_t, 1, allocator_t >::value_type = type_t

Represents the array value type.

◆ allocator_type

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::allocator_type = typename xtd::basic_array<type_t, allocator_t>::allocator_type

Represents the array allocator type.

◆ base_type

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::base_type = typename xtd::basic_array<type_t, allocator_t>::base_type

Represents the array base type.

◆ size_type

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::size_type = typename xtd::basic_array<type_t, allocator_t>::size_type

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

◆ difference_type

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::difference_type = typename xtd::basic_array<type_t, allocator_t>::difference_type

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

◆ reference

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::reference = typename xtd::basic_array<type_t, allocator_t>::reference

Represents the reference of array value type.

◆ const_reference

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::const_reference = typename xtd::basic_array<type_t, allocator_t>::const_reference

Represents the const reference of array value type.

◆ pointer

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::pointer = typename xtd::basic_array<type_t, allocator_t>::pointer

Represents the pointer of array value type.

◆ const_pointer

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::const_pointer = typename xtd::basic_array<type_t, allocator_t>::const_pointer

Represents the const pointer of array value type.

◆ iterator

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::iterator = typename xtd::basic_array<type_t, allocator_t>::iterator

Represents the iterator of array value type.

◆ const_iterator

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::const_iterator = typename xtd::basic_array<type_t, allocator_t>::const_iterator

Represents the const iterator of array value type.

◆ reverse_iterator

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::reverse_iterator = typename xtd::basic_array<type_t, allocator_t>::reverse_iterator

Represents the reverse iterator of array value type.

◆ const_reverse_iterator

template<typename type_t , typename allocator_t >
using xtd::array_< type_t, 1, allocator_t >::const_reverse_iterator = typename xtd::basic_array<type_t, allocator_t>::const_reverse_iterator

Represents the const reverse iterator of array value type.

Constructor & Destructor Documentation

◆ array_() [1/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( )
default

Initializes a new instance of the Array class that is empty.

Remarks
The Array class is not thread safe.
Examples
The following code example demonstrates different methods to create an array.

◆ array_() [2/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( const array_< type_t, 1, allocator_t > &  array)
inline

Copy constructor with specified array.

Parameters
arrayThe xtd::array which elements will be inserted from.

◆ array_() [3/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( const array_< type_t, 1, allocator_t > &&  array)
inline

Move constructor with specified array.

Parameters
arrayThe xtd::array which elements will be inserted from.

◆ array_() [4/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( const base_type array)
inline

Copy constructor with specified base type array.

Parameters
arrayThe xtd::array::base_type which elements will be inserted from.

◆ array_() [5/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( base_type &&  array)
inline

Move constructor with specified base type array.

Parameters
arrayThe xtd::array::base_type which elements will be moved from.

◆ array_() [6/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( size_type  length)
inline

Initializes a new instance of the array class with lengths for each rank specified.

Parameters
lengththe length for the first rank.
Remarks
The array class is not thread safe.
Examples
The following code example demonstrates different methods to create an array.

◆ array_() [7/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( std::initializer_list< type_t >  items)
inline

Constructs the container with the contents of the specified initializer list.

Parameters
itemsThe initializer list to initialize the elements of the container with.

◆ array_() [8/12]

template<typename type_t , typename allocator_t >
template<xtd::size length>
xtd::array_< type_t, 1, allocator_t >::array_ ( const type_t(&)  array[length])
inline

Initializes a new instance of the array and copy array[] type_t.

Parameters
arraythe array to copy.
Remarks
The array class is not thread safe.
Examples
The following code example demonstrates different methods to create an array.

◆ array_() [9/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( const type_t *  array,
size_type  length 
)
inline

Initializes a new instance of the array and copy array[] type_t with length specified.

Parameters
arraythe array to copy.
lengthlength of the array.
Remarks
The array class is not thread safe.
Examples
The following code example demonstrates different methods to create an array.

◆ array_() [10/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( const xtd::collections::generic::ienumerable< type_t > &  enumerable)
inline

Initializes a new instance of the array and copy array array specified.

Parameters
arraythe array to copy.
Remarks
The array class is not thread safe.
Examples
The following code example demonstrates different methods to create an array.

◆ array_() [11/12]

template<typename type_t , typename allocator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( const xtd::collections::generic::ilist< type_t > &  list)
inline

Initializes a new instance of the array and copy array array specified.

Parameters
arraythe array to copy.
Remarks
The array class is not thread safe.
Examples
The following code example demonstrates different methods to create an array.

◆ array_() [12/12]

template<typename type_t , typename allocator_t >
template<typename iterator_t >
xtd::array_< type_t, 1, allocator_t >::array_ ( iterator_t  first,
iterator_t  last 
)
inline

Constructs the container with the contents of the range [first, last).

Parameters
firstThe first iterator the range to copy the elements from.
lastThe last iterator the range to copy the elements from.

Member Function Documentation

◆ rank()

template<typename type_t , typename allocator_t >
xtd::size xtd::array_< type_t, 1, allocator_t >::rank ( ) const
inlineoverridevirtualnoexcept

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 from xtd::basic_array< type_t, allocator_t >.

◆ copy_to()

template<typename type_t , typename allocator_t >
void xtd::array_< type_t, 1, allocator_t >::copy_to ( xtd::array< type_t > &  array,
size_type  index 
) const
inlineoverridevirtual

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 32-bit integer.

Parameters
arrayThe one-dimensional array that is the destination of the elements copied from the current array.
indexThe index in array at which copying begins.
Exceptions
ArgumentOutOfRangeExceptionindex is less than the lower bound of array.
ArgumentExceptionarray is multidimensional. -or- The number of elements in the source array is greater than the available number of elements from index to the end of the destination array.
ArrayTypeMismatchExceptionThe type of the source Array cannot be cast automatically to the type of the destination array.
RankExceptionThe source array is multidimensional.
InvalidCastExceptionAt least one element in the source Array cannot be cast to the type of destination array.
Remarks
This method copies all the elements of the current array instance to the array destination array, starting at index index. The array destination array must already have been dimensioned and must have a sufficient number of elements to accommodate the copied elements. Otherwise, the method throws an exception.
This method supports the System.Collections.ICollection interface. If implementing System.Collections.ICollection is not explicitly required, use Copy to avoid an extra indirection.
If this method throws an exception while copying, the state of array is undefined.
This method is an O(n) operation, where n is Length.It performs a shallow copy only.
Examples
The following code example shows how to copy an Array to another native Array.

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

◆ get_value()

template<typename type_t , typename allocator_t >
const value_type & xtd::array_< type_t, 1, allocator_t >::get_value ( size_type  index) const
inline

Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.

Parameters
indexThe position of the Array element to get.
Returns
The value at the specified position in the one-dimensional Array.
Exceptions
ArgumentExceptionThe current Array does ! have exactly one dimension.
IndexOutOfRangeExceptionindex is outside the range of valid indexes for the current Array.

◆ set_value()

template<typename type_t , typename allocator_t >
void xtd::array_< type_t, 1, allocator_t >::set_value ( const value_type value,
size_type  index 
)
inline

Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.

Parameters
valueThe new value for the specified element.
indexThe position of the Array element to set.
Exceptions
ArgumentExceptionThe current Array does ! have exactly one dimension.
IndexOutOfRangeExceptionindex is outside the range of valid indexes for the current Array.

◆ operator()() [1/2]

template<typename type_t , typename allocator_t >
value_type & xtd::array_< type_t, 1, allocator_t >::operator() ( size_type  index)
inline

Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.

Parameters
valueThe new value for the specified element.
indexA 32-bit integer that represents the position of the Array element to set.
Exceptions
ArgumentExceptionThe current Array does ! have exactly one dimension.
IndexOutOfRangeExceptionindex is outside the range of valid indexes for 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 >
const value_type & xtd::array_< type_t, 1, allocator_t >::operator() ( size_type  index) const
inline

Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.

Parameters
indexA 32-bit integer that represents the position of the Array element to get.
Returns
The value at the specified position in the one-dimensional Array.
Exceptions
ArgumentExceptionThe current Array does ! have exactly one dimension.
IndexOutOfRangeExceptionindex is outside the range of valid indexes for the current Array.
Examples
The following code example shows how to use operator () to list the elements of an array.

◆ operator[]() [1/2]

template<typename type_t , typename allocator_t >
value_type & xtd::array_< type_t, 1, allocator_t >::operator[] ( size_type  index)
inlineoverridevirtual

Sets a value to the element at the specified position in the one-dimensional Array. The index is specified as a 32-bit integer.

Parameters
valueThe new value for the specified element.
indexA 32-bit integer that represents the position of the Array element to set.
Exceptions
ArgumentExceptionThe current Array does ! have exactly one dimension.
IndexOutOfRangeExceptionindex is outside the range of valid indexes for the current Array.
Examples
The following code example shows how to use operator [] to list the elements of an array.

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

◆ operator[]() [2/2]

template<typename type_t , typename allocator_t >
const value_type & xtd::array_< type_t, 1, allocator_t >::operator[] ( size_type  index) const
inlineoverridevirtual

Gets the element at the specified index.

Parameters
indexThe zero-based index of the element to get.
Returns
The value at the specified position in the one-dimensional Array.
Exceptions
ArgumentExceptionThe current Array does ! have exactly one dimension.
IndexOutOfRangeExceptionindex is less than 0 or index is equal to or greater than Count.
Examples
The following code example shows how to use operator [] to list the elements of an array.

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


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