6#if !defined(__XTD_ARRAY_INTERNAL__)
7#error "Do not include this file: Internal use only. Include <xtd/array> or <xtd/array.h> instead."
18 template<
class type_t, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
21 template<
class type_t, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
24 template<
class type_t, xtd::size length, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
27 template<
class type_t, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
30 template<
class type_t, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
33 template<
class type_t, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
36 template<
class type_t, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
39 template<
class type_t, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
42 template<
class type_t, xtd::size rank = 1,
class allocator_t = xtd::collections::
generic::helpers::allocator<type_to_array_t<type_t>>>
47template<
class type_t,
class allocator_t>
49 return operator()(indexes);
52template<
class type_t,
class allocator_t>
54 return xtd::string::format(
"[{}]", xtd::string::join(
", ", *
this));
57template<
class type_t,
class allocator_t>
60 for (
auto index1 =
xtd::size {0}; index1 < indexes.
size(); ++index1) {
63 for (
auto index2 = index1 + 1; index2 < indexes.
size(); ++index2)
64 multiplicand *= get_length(index2);
65 position += indexes[index1] * multiplicand;
68 return data_->items[position];
71template<
class type_t,
class allocator_t>
74 for (
auto index1 =
xtd::size {0}; index1 < indexes.
size(); ++index1) {
77 for (
auto index2 = index1 + 1; index2 < indexes.
size(); ++index2)
78 multiplicand *= get_length(index2);
79 position += indexes[index1] * multiplicand;
82 return data_->items[position];
85template<
class type_t,
class allocator_t>
86inline xtd::basic_array<type_t, allocator_t>::basic_array(
const array<size_type, 1>& lengths) : basic_array(lengths, value_type {}) {
89template<
class type_t,
class allocator_t>
90inline xtd::basic_array<type_t, allocator_t>::basic_array(
const array<size_type, 1>& lengths,
const value_type& value) {
91 data_->items = base_type(lengths.aggregate([&](
const size_type & accumulator,
const size_type & value) {return accumulator * value;}));
92 data_->lower_bound.clear();
93 data_->upper_bound.clear();
94 for (
auto length : lengths) {
95 data_->lower_bound.push_back(0);
96 data_->upper_bound.push_back(length - 1);
100template<
class type_t,
class allocator_t>
102 return xtd::collections::object_model::read_only_collection<type_t> {array};
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:61
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 ...
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
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 ...
virtual size_type size() const noexcept
Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(),...
Definition basic_array.hpp:246
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.
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:59
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
@ a
The A key.
Definition console_key.hpp:88
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
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.