6#if !defined(__XTD_ARRAY_INTERNAL__)
7#error "Do not include this file: Internal use only. Include <xtd/array> or <xtd/array.hpp> instead."
18 template<
class type_t, xtd::size length>
21 template<
class type_t>
24 template<
class type_t>
27 template<
class type_t>
30 template <
class input_iterator_t>
33 template<
class type_t>
36 template<
class type_t>
39 template<
class type_t>
42 template<
class type_t>
45 template<
class type_t>
48 template<
class type_t>
51 template<
class type_t>
52 array(std::initializer_list<std::initializer_list<std::initializer_list<type_t>>>) ->
array<type_t, 3>;
56template<
class type_t,
class allocator_t>
58 return operator()(indexes);
61template<
class type_t,
class allocator_t>
65 result[r] = get_length(r);
69template<
class type_t,
class allocator_t>
74template<
class type_t,
class allocator_t>
77 for (
auto index1 =
xtd::size {0}; index1 < indexes.
length(); ++index1) {
80 for (
auto index2 = index1 + 1; index2 < indexes.
length(); ++index2)
81 multiplicand *= get_length(index2);
82 position += indexes[index1] * multiplicand;
85 return data_->items[position];
88template<
class type_t,
class allocator_t>
90 return data_->items[compute_index(
self_, indexes)];
93template<
class type_t,
class allocator_t>
94inline xtd::basic_array<type_t, allocator_t>::basic_array(
const array<size_type, 1>& lengths) : basic_array(lengths, value_type {}) {
97template<
class type_t,
class allocator_t>
98inline xtd::basic_array<type_t, allocator_t>::basic_array(
const array<size_type, 1>& lengths,
const value_type& value) {
99 data_->items = base_type(lengths.aggregate([&](
const size_type & accumulator,
const size_type & value) {return accumulator * value;}), value);
100 data_->lower_bound.clear();
101 data_->upper_bound.clear();
102 for (
auto length : lengths) {
103 data_->lower_bound.push_back(0);
104 data_->upper_bound.push_back(length - 1);
108template<
class type_t,
class allocator_t>
109template<
class value_t>
112 for (
auto index1 =
xtd::size {0}; index1 < indexes.
length(); ++index1) {
115 for (
auto index2 = index1 + 1; index2 < indexes.
length(); ++index2)
117 position += indexes[index1] * multiplier;
123template<
class type_t,
class allocator_t>
124template<
class value_t>
128 for (
auto r = rank + 1;
r < items.
rank(); ++
r)
134template<
class type_t,
class allocator_t>
135template<
class value_t>
140 auto offset = base_index + compute_index(items, rank, index);
141 if (rank + 1 < items.
rank()) result +=
to_string(items, rank + 1, offset);
148template<
class type_t,
class allocator_t>
150 return xtd::collections::object_model::read_only_collection<type_t> {array};
153template<
class type_t, xtd::size rank_,
class allocator_t>
158template<
class type_t,
class allocator_t>
163template<
class type_t,
class allocator_t>
168template<
class type_t,
class allocator_t>
175namespace xtd::collections::generic::extensions {
176 template <
class enumerable_t,
class source_t>
177 inline xtd::array<source_t> enumerable<enumerable_t, source_t>::to_array() const noexcept {
183 template <
class source_t>
184 inline auto enumerable::to_array(
const xtd::collections::generic::ienumerable<source_t>& source)
noexcept {
185 auto result = xtd::array<source_t> {};
186 result = xtd::array<source_t> {source};
static xtd::collections::object_model::read_only_collection< type_t > as_read_only(const xtd::array< type_t, 1, allocator_t > &array)
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
virtual size_type rank() const noexcept
Gets the rank (number of dimensions) of the array.
Definition basic_array.hpp:139
const value_type & 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 ...
constexpr size_type get_length(size_type dimension) const
Gets the total number of elements in all the dimensions of the array.
Definition basic_array.hpp:260
constexpr size_type get_lower_bound(size_type dimension) const
Gets the lower bound of the specified dimension in the array.
Definition basic_array.hpp:282
virtual size_type length() const noexcept
Gets a size that represents the total number of elements in all the dimensions of the array.
Definition basic_array.hpp:124
constexpr size_type get_upper_bound(size_type dimension) const
Gets the upper bound of the specified dimension in the array.
Definition basic_array.hpp:294
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
xtd::array< size_type, 1 > get_lengths() const
Gets an array of the number of elements of all the dimensions of the array.
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 ...
static basic_string join(const basic_string &separator, const collection_t &values) noexcept
Definition basic_string.hpp:1702
Provides the base class for a generic read-only collection.
Definition read_only_collection.hpp:38
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
static auto to_array(const ienumerable< source_t > &source) noexcept
Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
@ 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
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
@ r
The R key.
Definition console_key.hpp:122
@ relative
The xtd::uri is a relative xtd::uri.
Definition uri_kind.hpp:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
string to_string() const noexcept override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:375
constexpr size_type length() const noexcept
Returns the length of the current read_only_span.
Definition read_only_span.hpp:229
Contains xtd::collections::object_model::read_only_collection class.
Contains xtd::string alias.