xtd 0.2.0
Loading...
Searching...
No Matches
array.hpp
Go to the documentation of this file.
1
4#pragma once
5#define __XTD_CORE_INTERNAL__
8#undef __XTD_CORE_INTERNAL__
15#include "abstract.hpp"
16#include "byte.hpp"
17#include "core_export.hpp"
18#include "int64.hpp"
19#include "iequatable.hpp"
20#include "new_ptr.hpp"
21#include "null.hpp"
22#include "object.hpp"
23#include "self.hpp"
24#include "static.hpp"
25#include <algorithm>
26
27#define __XTD_ARRAY_INTERNAL__
29#include "basic_array.hpp"
30#undef __XTD_ARRAY_INTERNAL__
31
33namespace xtd {
62 template<class type_t, xtd::size rank_, class allocator_t>
63 class array : public basic_array<type_t, allocator_t> {
64 public:
66
73 array() = default;
74
81 array(const array<xtd::size, 1>& lengths) : xtd::basic_array<type_t, allocator_t>(lengths) {}
83
85 array(const array& array) : xtd::basic_array<type_t, allocator_t>(array) {}
86 array(array&& array) = default;
88
90
92 xtd::size rank() const noexcept override {return rank_;}
94
96
98 array& operator=(const array&) = default;
99 array& operator=(array&&) = default;
101
102 private:
103 friend class array<>;
104 array(const array<xtd::size>& lengths, bool) : basic_array<type_t, allocator_t>(lengths) {}
105 };
106}
107
108#define __XTD_ARRAY_INTERNAL__
109#include "array_1.hpp"
110#include "array_2.hpp"
111#include "array_3.hpp"
112#include "array_static.hpp"
113#include "array_.hpp"
114#undef __XTD_ARRAY_INTERNAL__
115#define __XTD_CORE_INTERNAL__
117#undef __XTD_CORE_INTERNAL__
118
120template<class source_t>
121auto xtd::linq::enumerable::chunk(const ienumerable<source_t>& source, size_t size) {
123 auto chunks = __opaque_xtd_linq_enumerable_collection__<xtd::array<source_t>> {};
124 chunks = __opaque_xtd_linq_enumerable_collection__<xtd::array<source_t>> {};
125 auto chunk = std::vector<source_t> {};
126 for (auto index = size_t {0}; const auto& item : source) {
127 chunk.push_back(item);
128 if (++index % size == 0) {
129 chunks.items.push_back(chunk);
130 chunk = std::vector<source_t> {};
131 }
132 }
133 if (chunk.size() != 0) chunks.items.push_back(chunk);
134
135 return chunks;
136}
Contains xtd::array definitions.
Contains xtd_raw_array_data class.
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.
Contains xtd::byte type.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:63
array(const array< xtd::size, 1 > &lengths)
Initializes a new instance of the array class with lengths for each rank specified.
Definition array.hpp:81
xtd::size rank() const noexcept override
Gets the rank (number of dimensions) of the array.
Definition array.hpp:92
array()=default
Initializes a new instance of the array class that is empty.
Base object that represent array.
Definition basic_array.hpp:27
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 chunk(const ienumerable< source_t > &source, xtd::size size)
Splits the elements of a sequence into chunks of size at most size.
Contains core_export_ keyword.
Contains xtd::collections::generic::helpers::equator struct.
Contains xtd::collections::generic::comparer <type_t> class.
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.
Definition exception_case.hpp:35
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 abstract_object.hpp:8
Contains xtd::new_ptr method.
Contains xtd::null pointer valiue.
Contains xtd::object class.
Contains self_ keyword.
Contains xtd::static_object class.
Contains xtd::helpers::exception_case enum class.