xtd 1.0.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<typename type_t, typename 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) requires std::copy_constructible<type_t> : 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) requires std::copy_constructible<type_t> : 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::usize> {length}) {}
108 array(size_type length, const value_type& value) requires std::copy_constructible<type_t> : basic_array<type_t, allocator_t>(array<xtd::usize> {length}, value) {}
115 array(const array<xtd::usize, 1>& lengths, const value_type& value) requires std::copy_constructible<type_t> : basic_array<type_t, allocator_t>(lengths, value) {}
122 template<xtd::usize length>
123 array(const type_t(&array)[length]) requires std::copy_constructible<type_t> : basic_array<type_t, allocator_t>(array, length) {}
131 array(const type_t* array, size_type length) requires std::copy_constructible<type_t> : basic_array<type_t, allocator_t>(array, length) {}
138 explicit array(const xtd::collections::generic::ienumerable<type_t>& enumerable) requires std::copy_constructible<type_t> : basic_array<type_t, allocator_t>(enumerable) {}
145 explicit array(const xtd::collections::generic::ilist<type_t>& list) requires std::copy_constructible<type_t> : basic_array<type_t, allocator_t>(list) {}
149 template<typename input_iterator_t>
150 array(input_iterator_t first, input_iterator_t last) requires std::copy_constructible<type_t> : basic_array<type_t, allocator_t>(first, last) {}
153 array(std::initializer_list<type_t> items) requires std::copy_constructible<type_t> : basic_array<type_t, allocator_t>(items) {}
155
157
164 [[nodiscard]] auto rank() const noexcept -> xtd::usize override {return 1;}
166
168
170
185 auto copy_to(xtd::array<type_t>& array, size_type index) const -> void override {
186 if constexpr (std::copy_constructible<type_t>) basic_array<type_t, allocator_t>::copy_to(array, index);
187 else xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::invalid_operation, "value_type is not copy constructible.");
188 }
189
190 using xtd::basic_array<type_t, allocator_t>::get_value;
196 [[nodiscard]] auto get_value(size_type index) const -> const value_type& {return operator()(index);}
197
198 using xtd::basic_array<type_t, allocator_t>::set_value;
204 auto set_value(const value_type& value, size_type index) -> void requires std::copy_constructible<type_t> {operator()(index) = value;}
205
208 [[nodiscard]] auto to_string() const noexcept -> xtd::string override;
210
212
217 auto operator=(const array&) -> array& requires std::copy_constructible<type_t> = default;
221 auto operator=(array&&) -> array& = default;
222
223 using xtd::basic_array<type_t, allocator_t>::operator();
232 [[nodiscard]] auto operator()(size_type index) -> value_type& {return xtd::basic_array<type_t, allocator_t>::operator[](index);}
233
242 [[nodiscard]] auto operator()(size_type index) const -> const value_type& {return xtd::basic_array<type_t, allocator_t>::operator[](index);}
243
252 [[nodiscard]] auto operator[](size_type index) -> value_type& override {return xtd::basic_array<type_t, allocator_t>::operator[](index);}
253
262 [[nodiscard]] auto operator[](size_type index) const -> const value_type& override {return xtd::basic_array<type_t, allocator_t>::operator[](index);}
264 };
265}
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
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
auto rank() const noexcept -> xtd::usize override
Gets the rank (number of dimensions) of the array.
Definition array_1.hpp:164
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(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
array(base_type &&array)
Move constructor with specified base type array.
Definition array_1.hpp:93
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
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
auto to_string() const noexcept -> xtd::string override
Returns a xtd::string that represents the current object.
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
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:262
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
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:196
array(const base_type &array)
Copy constructor with specified base type array.
Definition array_1.hpp:90
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:242
array(const array &array)
Copy constructor with specified array.
Definition array_1.hpp:84
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:252
typename xtd::basic_array< type_t, allocator_t >::reference reference
Represents the reference of array value type.
Definition array_1.hpp:56
array(const type_t(&array)[length])
Initializes a new instance of the array and copy array[] type_t.
Definition array_1.hpp:123
array(const array< xtd::usize, 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
typename xtd::basic_array< type_t, allocator_t >::size_type size_type
Represents the array size type (usually xtd::usize).
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(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
array(std::initializer_list< type_t > items)
Constructs the container with the contents of the specified initializer list.
Definition array_1.hpp:153
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:204
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 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
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:177
xtd::ptrdiff difference_type
Represents the array difference type (usually xtd::ptrdiff).
Definition basic_array.hpp:41
xtd::usize size_type
Represents the array size type (usually xtd::usize).
Definition basic_array.hpp:39
virtual auto items() const noexcept -> const base_type &
Definition basic_array.hpp:111
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:379
virtual auto length() const noexcept -> size_type
Definition basic_array.hpp:122
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:461
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
typename xtd::linq::enumerable::list< type_t > list
Definition enumerable.hpp:47
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
Represents a collection of objects that can be individually accessed by index.
Definition ilist.hpp:43
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
auto first() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:249
auto last() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:274