6#if !defined(__XTD_ARRAY_INTERNAL__)
7#error "Do not include this file: Internal use only. Include <xtd/array> or <xtd/array.hpp> instead."
19 template<
typename type_t, xtd::usize length>
22 template<
typename type_t>
25 template<
typename type_t>
28 template<
typename type_t>
31 template<
typename input_iterator_t>
34 template<
typename type_t>
37 template<
typename type_t>
40 template<
typename type_t>
43 template<
typename type_t>
46 template<
typename type_t>
49 template<
typename type_t>
52 template<
typename type_t>
53 array(std::initializer_list<std::initializer_list<std::initializer_list<type_t>>>) ->
array<type_t, 3>;
57template<
typename type_t,
typename allocator_t>
62template<
typename type_t,
typename allocator_t>
66 result[r] = get_length(r);
70template<
typename type_t,
typename allocator_t>
75template<
typename type_t,
typename allocator_t>
76template<xtd::
integer index_t>
78 return data_->items[compute_index(
self_, indexes)];
81template<
typename type_t,
typename allocator_t>
82template<xtd::
integer index_t>
84 return data_->items[compute_index(
self_, indexes)];
87template<
typename type_t,
typename allocator_t>
88template<xtd::
integer index_t>
93template<
typename type_t,
typename allocator_t>
94template<xtd::
integer index_t>
99template<
typename type_t,
typename allocator_t>
100template<xtd::
integer index_t>
102 return operator [](indexes);
105template<
typename type_t,
typename allocator_t>
106template<xtd::
integer index_t>
108 return operator [](indexes);
111template<
typename type_t,
typename allocator_t>
112template<xtd::
integer index_t>
117template<
typename type_t,
typename allocator_t>
118template<xtd::
integer index_t>
123template<
typename type_t,
typename allocator_t>
124inline xtd::basic_array<type_t, allocator_t>::basic_array(
const array<size_type, 1>& lengths) {
125 data_->items = base_type(lengths.aggregate([&](
const size_type & accumulator,
const size_type & value) {return accumulator * value;}));
126 data_->lower_bound.clear();
127 data_->upper_bound.clear();
128 for (
auto length : lengths) {
129 data_->lower_bound.push_back(0);
130 data_->upper_bound.push_back(length - 1);
134template<
typename type_t,
typename allocator_t>
135inline xtd::basic_array<type_t, allocator_t>::basic_array(
const array<size_type, 1>& lengths,
const value_type& value) {
136 data_->items = base_type(lengths.aggregate([&](
const size_type & accumulator,
const size_type & value) {return accumulator * value;}), value);
137 data_->lower_bound.clear();
138 data_->upper_bound.clear();
139 for (
auto length : lengths) {
140 data_->lower_bound.push_back(0);
141 data_->upper_bound.push_back(length - 1);
145template<
typename type_t,
typename allocator_t>
146template<
typename value_t, xtd::
integer index_t>
152 for (
auto index2 = index1 + 1; index2 < indexes.
length(); ++index2)
154 position +=
static_cast<size_type>(indexes[index1]) * multiplier;
160template<
typename type_t,
typename allocator_t>
161template<
typename value_t, xtd::
integer index_t>
165 for (
auto r = rank + 1;
r < items.
rank(); ++
r)
171template<
typename type_t,
typename allocator_t>
172template<
typename value_t>
174 if (!items.
size())
return "[]";
178 auto offset = base_index + compute_index(items, rank, index);
179 if (rank + 1 < items.
rank()) result +=
to_string(items, rank + 1, offset);
186template<
typename type_t,
typename allocator_t>
188 return xtd::collections::object_model::read_only_collection<type_t> {array};
191template<
typename type_t, xtd::usize rank_,
typename allocator_t>
196template<
typename type_t,
typename allocator_t>
201template<
typename type_t,
typename allocator_t>
206template<
typename type_t,
typename allocator_t>
211template<
typename type_t,
typename allocator_t>
213 return data_->items[compute_index(
self_, indexes)];
216template<
typename type_t,
typename allocator_t>
218 return data_->items[compute_index(
self_, indexes)];
221template<
typename type_t,
typename allocator_t>
223 return data_->items[compute_index(
self_, xtd::array<xtd::index> {indexes})];
226template<
typename type_t,
typename allocator_t>
228 return data_->items[compute_index(
self_, xtd::array<xtd::index> {indexes})];
231template<
typename type_t,
typename allocator_t>
233 return data_->items[compute_index(
self_, indexes)];
236template<
typename type_t,
typename allocator_t>
238 return data_->items[compute_index(
self_, indexes)];
241template<
typename type_t,
typename allocator_t>
243 return data_->items[compute_index(
self_, xtd::array<xtd::index> {indexes})];
246template<
typename type_t,
typename allocator_t>
248 return data_->items[compute_index(
self_, xtd::array<xtd::index> {indexes})];
251template<
typename type_t,
typename allocator_t>
252template<
typename value_t>
253xtd::usize xtd::basic_array<type_t, allocator_t>::compute_index(
const xtd::basic_array<value_t>& items,
const xtd::array <xtd::index>& indexes) {
254 auto size_type_indexes = xtd::array <size_type>(indexes.
length());
257 return compute_index(items, size_type_indexes);
260#if __cpp_multidimensional_subscript
261template<
typename type_t,
typename allocator_t>
266template<
typename type_t,
typename allocator_t>
271template<
typename type_t,
typename allocator_t>
276template<
typename type_t,
typename allocator_t>
282template<
typename type_t,
typename allocator_t>
287template<
typename type_t,
typename allocator_t>
292template<
typename type_t,
typename allocator_t>
297template<
typename type_t,
typename allocator_t>
static auto as_read_only(const xtd::array< type_t, 1, allocator_t > &array) -> xtd::collections::object_model::read_only_collection< type_t >
Returns a read-only wrapper for the specified array.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
Base object that represent array.
Definition basic_array.hpp:27
auto get_value(const xtd::array< size_type > &indexes) const -> const value_type &
Gets the value at the specified position in the multidimensional array. The indexes are specified as ...
virtual auto rank() const noexcept -> size_type
Gets the rank (number of dimensions) of the array.
Definition basic_array.hpp:137
auto get_lengths() const -> xtd::array< size_type, 1 >
Gets an array of the number of elements of all the dimensions of the array.
constexpr auto get_length(size_type dimension) const -> size_type
Gets the total number of elements in all the dimensions of the array.
Definition basic_array.hpp:286
auto operator()(const xtd::array< index_t > &indexes) -> type_t &
Gets the value at the specified position in the multidimensional array. The indexes are specified as ...
virtual auto length() const noexcept -> size_type
Gets a size that represents the total number of elements in all the dimensions of the array.
Definition basic_array.hpp:122
auto operator[](size_type index) const -> const_reference override
Returns a reference to the element at specified location index.
Definition basic_array.hpp:516
constexpr auto get_lower_bound(size_type dimension) const -> size_type
Gets the lower bound of the specified dimension in the array.
Definition basic_array.hpp:308
constexpr auto get_upper_bound(size_type dimension) const -> size_type
Gets the upper bound of the specified dimension in the array.
Definition basic_array.hpp:320
static auto join(const basic_string &separator, const collection_t &values) noexcept -> basic_string
Definition basic_string.hpp:1240
virtual auto size() const noexcept -> xtd::usize
Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
Definition collection_common.hpp:43
virtual auto operator[](xtd::usize index) const -> const type_t &=0
Gets the element at the specified index.
Provides the base class for a generic read-only collection.
Definition read_only_collection.hpp:39
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
virtual auto to_string() const -> xtd::string
Returns a xtd::string that represents the current object.
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:61
@ rank
The rank is not valid.
Definition exception_case.hpp:93
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
@ r
The R key.
Definition console_key.hpp:122
@ relative
The xtd::uri is a relative xtd::uri.
Definition uri_kind.hpp:25
Contains xtd::index struct.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
auto to_string() const noexcept -> xtd::string override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:354
xtd::usize size_type
Represents the read_only_span size type (usually xtd::usize).
Definition read_only_span.hpp:65
constexpr auto length() const noexcept -> size_type
Returns the length of the current read_only_span.
Definition read_only_span.hpp:209
auto operator()(size_type index) const -> const_reference
Gets the element at the specified zero-based index.
Definition read_only_span.hpp:401
Contains xtd::collections::object_model::read_only_collection class.
Contains xtd::string alias.
Represents a type that can be used to index a collection either from the beginning or the end.
Definition index.hpp:38
Represents a value_type struct.
Definition value_type.hpp:34