xtd 0.2.0
array.hpp
Go to the documentation of this file.
1
4#pragma once
5#define __XTD_CORE_INTERNAL__
7#undef __XTD_CORE_INTERNAL__
13#include "abstract.hpp"
14#include "core_export.hpp"
15#include "int64.hpp"
16#include "iequatable.hpp"
17#include "new_ptr.hpp"
18#include "object.hpp"
19#include "static.hpp"
20#include <algorithm>
21#include <vector>
22
23#define __XTD_ARRAY_INTERNAL__
25#include "basic_array.hpp"
26#undef __XTD_ARRAY_INTERNAL__
27
29namespace xtd {
58 template<class type_t, xtd::size rank_, class allocator_t>
59 class array : public basic_array<type_t, allocator_t> {
60 public:
62
69 array() = default;
70
77 array(const array<xtd::size, 1>& lengths) : xtd::basic_array<type_t, allocator_t>(lengths) {}
79
81 array(const array& array) : xtd::basic_array<type_t, allocator_t>(array) {}
82 array(array&& array) = default;
84
86
88 xtd::size rank() const noexcept override {return rank_;}
90
92
94 array& operator=(const array&) = default;
95 array& operator=(array&&) = default;
97
98 private:
99 friend class array<>;
100 array(const array<xtd::size>& lengths, bool) : basic_array<type_t, allocator_t>(lengths) {}
101 };
102}
103
104#define __XTD_ARRAY_INTERNAL__
105#include "array_1.hpp"
106#include "array_2.hpp"
107#include "array_3.hpp"
108#include "array_static.hpp"
109#include "array_.hpp"
110#undef __XTD_ARRAY_INTERNAL__
111#define __XTD_CORE_INTERNAL__
113#undef __XTD_CORE_INTERNAL__
114
116template<class source_t>
117const xtd::linq::enumerable::ienumerable<xtd::array<source_t>>& xtd::linq::enumerable::chunk(const ienumerable<source_t>& source, size_t size) {
119 static thread_local auto chunks = __opaque_xtd_linq_enumerable_collection__<xtd::array<source_t>> {};
120 chunks = __opaque_xtd_linq_enumerable_collection__<xtd::array<source_t>> {};
121 auto chunk = std::vector<source_t> {};
122 for (auto index = size_t {0}; const auto& item : source) {
123 chunk.push_back(item);
124 if (++index % size == 0) {
125 chunks.items.push_back(chunk);
126 chunk = std::vector<source_t> {};
127 }
128 }
129 if (chunk.size() != 0) chunks.items.push_back(chunk);
130
131 return static_cast<const xtd::linq::enumerable::ienumerable<xtd::array<source_t>>&>(chunks);
132}
Contains xtd::array definitions.
Contains xtd::abstract_object class.
Contains xtd::array <type_t, 1> class.
Contains xtd::array <type_t, 2> class.
Contains xtd::array <type_t, 3> class.
Contains xtd::array class.
Contains xtd::array_abstract_object class.
Contains xtd::array <> class.
Contains xtd::basic_array class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:59
array(const array< xtd::size, 1 > &lengths)
Initializes a new instance of the array class with lengths for each rank specified.
Definition array.hpp:77
xtd::size rank() const noexcept override
Gets the rank (number of dimensions) of the array.
Definition array.hpp:88
array()=default
Initializes a new instance of the array class that is empty.
Base object that represent array.
Definition basic_array.hpp:44
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
static const ienumerable< xtd::array< source_t > > & chunk(const ienumerable< source_t > &source, xtd::size size)
Splits the elements of a sequence into chunks of size at most size.
typename xtd::collections::generic::ienumerable< type_t > ienumerable
Represents the ienumerable value type.
Definition enumerable.hpp:66
Contains core_export_ keyword.
Contains xtd::collections::generic::helpers::equator struct.
Contains xtd::collections::generic::enumerator <type_t> class.
Contains xtd::collections::generic::icomparer <type_t> interface.
Contains xtd::collections::generic::ilist <type_t> interface.
@ argument_out_of_range
The argument is out of range.
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
Contains xtd::iequatable interface.
Contains xtd::int64 type.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Contains xtd::new_ptr method.
Contains xtd::object class.
Contains xtd::static_object class.
Contains xtd::helpers::exception_case enum class.