xtd 0.2.0
Loading...
Searching...
No Matches
array_1.hpp
Go to the documentation of this file.
1
4
5#if !defined(__XTD_ARRAY_INTERNAL__)
6#error "Do not include this file: Internal use only. Include <xtd/array> or <xtd/array.hpp> instead."
7#endif
8
10namespace xtd {
39 template<class type_t, class allocator_t>
40 class array<type_t, 1, allocator_t> : public xtd::basic_array<type_t, allocator_t> {
41 public:
43
46 using value_type = type_t;
72
74
81 array() = default;
84 array(const array& array) : basic_array<type_t, allocator_t>(array) {}
87 array(array&& array) : basic_array<type_t, allocator_t>(std::move(array)) {}
90 array(const base_type& array) : basic_array<type_t, allocator_t>(array) {}
93 array(base_type&& array) : basic_array<type_t, allocator_t>(std::move(array)) {}
100 explicit array(size_type length) : basic_array<type_t, allocator_t>(array<xtd::size> {length}) {}
108 array(size_type length, const value_type& value) : basic_array<type_t, allocator_t>(array<xtd::size> {length}, value) {}
115 array(const array<xtd::size, 1>& lengths, const value_type& value) : basic_array<type_t, allocator_t>(lengths, value) {}
122 template<xtd::size length>
123 array(const type_t(&array)[length]) : basic_array<type_t, allocator_t>(array, length) {}
131 array(const type_t* array, size_type length) : basic_array<type_t, allocator_t>(array, length) {}
138 explicit array(const xtd::collections::generic::ienumerable<type_t>& enumerable) : basic_array<type_t, allocator_t>(enumerable) {}
145 explicit array(const xtd::collections::generic::ilist<type_t>& list) : basic_array<type_t, allocator_t>(list) {}
149 template<class input_iterator_t>
150 array(input_iterator_t first, input_iterator_t last) : basic_array<type_t, allocator_t>(first, last) {}
153 array(std::initializer_list<type_t> items) : basic_array<type_t, allocator_t>(items) {}
155
157
164 [[nodiscard]] auto rank() const noexcept -> xtd::size override {return 1;}
166
168
170
186
187 using xtd::basic_array<type_t, allocator_t>::get_value;
193 [[nodiscard]] auto get_value(size_type index) const -> const value_type& {return operator()(index);}
194
195 using xtd::basic_array<type_t, allocator_t>::set_value;
201 auto set_value(const value_type& value, size_type index) -> void {operator()(index) = value;}
202
205 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
207
209
214 auto operator=(const array&) -> array& = default;
218 auto operator=(array&&) -> array& = default;
219
220 using xtd::basic_array<type_t, allocator_t>::operator();
229 [[nodiscard]] auto operator()(size_type index) -> value_type& {return xtd::basic_array<type_t, allocator_t>::operator[](index);}
230
239 [[nodiscard]] auto operator()(size_type index) const -> const value_type& {return xtd::basic_array<type_t, allocator_t>::operator[](index);}
240
249 [[nodiscard]] auto operator[](size_type index) -> value_type& override {return xtd::basic_array<type_t, allocator_t>::operator[](index);}
250
259 [[nodiscard]] auto operator[](size_type index) const -> const value_type& override {return xtd::basic_array<type_t, allocator_t>::operator[](index);}
261 };
262}
array(size_type length)
Initializes a new instance of the array class with lengths for each rank specified.
Definition array_1.hpp:100
auto copy_to(xtd::array< type_t > &array, size_type index) const -> void override
Copies all the elements of the current one-dimensional array to the specified one-dimensional array s...
Definition array_1.hpp:185
array(input_iterator_t first, input_iterator_t last)
Constructs the container with the contents of the range [first, last).
Definition array_1.hpp:150
typename xtd::basic_array< type_t, allocator_t >::const_reference const_reference
Represents the const reference of array value type.
Definition array_1.hpp:58
typename xtd::basic_array< type_t, allocator_t >::const_pointer const_pointer
Represents the const pointer of array value type.
Definition array_1.hpp:62
array(base_type &&array)
Move constructor with specified base type array.
Definition array_1.hpp:93
array(const xtd::collections::generic::ienumerable< type_t > &enumerable)
Initializes a new instance of the array and copy array array specified.
Definition array_1.hpp:138
array(const xtd::collections::generic::ilist< type_t > &list)
Initializes a new instance of the array and copy array array specified.
Definition array_1.hpp:145
typename xtd::basic_array< type_t, allocator_t >::difference_type difference_type
Represents the array difference type (usually xtd::ptrdiff).
Definition array_1.hpp:54
auto to_string() const noexcept -> xtd::string override
Returns a xtd::string that represents the current object.
array(size_type length, const value_type &value)
Initializes a new instance of the array class with lengths for each rank specified and default value.
Definition array_1.hpp:108
typename xtd::basic_array< type_t, allocator_t >::reverse_iterator reverse_iterator
Represents the reverse iterator of array value type.
Definition array_1.hpp:68
array()=default
Initializes a new instance of the Array class that is empty.
typename xtd::basic_array< type_t, allocator_t >::pointer pointer
Represents the pointer of array value type.
Definition array_1.hpp:60
typename xtd::basic_array< type_t, allocator_t >::const_iterator const_iterator
Represents the const iterator of array value type.
Definition array_1.hpp:66
auto set_value(const value_type &value, size_type index) -> void
Sets a value to the element at the specified position in the one-dimensional Array....
Definition array_1.hpp:201
typename xtd::basic_array< type_t, allocator_t >::iterator iterator
Represents the iterator of array value type.
Definition array_1.hpp:64
array(array &&array)
Move constructor with specified array.
Definition array_1.hpp:87
typename xtd::basic_array< type_t, allocator_t >::const_reverse_iterator const_reverse_iterator
Represents the const reverse iterator of array value type.
Definition array_1.hpp:70
auto operator[](size_type index) const -> const value_type &override
Gets the element at the specified index.
Definition array_1.hpp:259
array(std::initializer_list< type_t > items)
Constructs the container with the contents of the specified initializer list.
Definition array_1.hpp:153
auto get_value(size_type index) const -> const value_type &
Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32...
Definition array_1.hpp:193
array(const array< xtd::size, 1 > &lengths, const value_type &value)
Initializes a new instance of the array class with lengths for each rank specified.
Definition array_1.hpp:115
array(const array &array)
Copy constructor with specified array.
Definition array_1.hpp:84
auto rank() const noexcept -> xtd::size override
Gets the rank (number of dimensions) of the array.
Definition array_1.hpp:164
typename xtd::basic_array< type_t, allocator_t >::base_type base_type
Represents the array base type.
Definition array_1.hpp:50
auto operator()(size_type index) const -> const value_type &
Gets the value at the specified position in the one-dimensional Array. The index is specified as a 32...
Definition array_1.hpp:239
auto operator[](size_type index) -> value_type &override
Sets a value to the element at the specified position in the one-dimensional Array....
Definition array_1.hpp:249
typename xtd::basic_array< type_t, allocator_t >::reference reference
Represents the reference of array value type.
Definition array_1.hpp:56
array(const base_type &array)
Copy constructor with specified base type array.
Definition array_1.hpp:90
array(const type_t(&array)[length])
Initializes a new instance of the array and copy array[] type_t.
Definition array_1.hpp:123
typename xtd::basic_array< type_t, allocator_t >::size_type size_type
Represents the array size type (usually xtd::size).
Definition array_1.hpp:52
typename xtd::basic_array< type_t, allocator_t >::allocator_type allocator_type
Represents the array allocator type.
Definition array_1.hpp:48
array(const type_t *array, size_type length)
Initializes a new instance of the array and copy array[] type_t with length specified.
Definition array_1.hpp:131
type_t value_type
Represents the array value type.
Definition array_1.hpp:46
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Base object that represent array.
Definition basic_array.hpp:27
const value_type & const_reference
Represents the const reference of array value type.
Definition basic_array.hpp:45
xtd::collections::generic::helpers::allocator< value_type > allocator_type
Represents the array allocator type.
Definition basic_array.hpp:35
auto copy_to(xtd::array< type_t > &array) const -> void
Copies the entire xtd::array <type_t> to a compatible one-dimensional array.
Definition basic_array.hpp:179
auto get_value(const xtd::array< size_type > &indexes) const -> const value_type &
typename xtd::collections::generic::ienumerable< type_t >::const_iterator const_iterator
Represents the const iterator of array value type.
Definition basic_array.hpp:53
xtd::ptrdiff difference_type
Represents the array difference type (usually xtd::ptrdiff).
Definition basic_array.hpp:41
virtual auto items() const noexcept -> const base_type &
Definition basic_array.hpp:113
const value_type * const_pointer
Represents the const pointer of array value type.
Definition basic_array.hpp:49
typename xtd::collections::generic::helpers::raw_array< value_type >::reverse_iterator reverse_iterator
Represents the reverse iterator of array value type.
Definition basic_array.hpp:55
value_type * pointer
Represents the pointer of array value type.
Definition basic_array.hpp:47
value_type & reference
Represents the reference of array value type.
Definition basic_array.hpp:43
auto operator()(const xtd::array< size_type > &indexes) -> type_t &
auto set_value(const type_t &value, const xtd::array< size_type > &indexes) -> void
Definition basic_array.hpp:342
virtual auto length() const noexcept -> size_type
Definition basic_array.hpp:124
typename xtd::collections::generic::helpers::raw_array< value_type, allocator_type >::base_type base_type
Represents the array base type.
Definition basic_array.hpp:37
auto operator[](size_type index) const -> const_reference override
Returns a reference to the element at specified location index.
Definition basic_array.hpp:424
typename xtd::collections::generic::helpers::raw_array< value_type >::const_reverse_iterator const_reverse_iterator
Represents the const reverse iterator of array value type.
Definition basic_array.hpp:57
typename xtd::collections::generic::ienumerable< type_t >::iterator iterator
Represents the iterator of array value type.
Definition basic_array.hpp:51
xtd::size size_type
Represents the array size type (usually xtd::size).
Definition basic_array.hpp:39
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307