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__
7#undef __XTD_CORE_INTERNAL__
16#include "abstract.hpp"
17#include "byte.hpp"
18#include "core_export.hpp"
19#include "int64.hpp"
20#include "iequatable.hpp"
21#include "new_ptr.hpp"
22#include "null.hpp"
23#include "object.hpp"
24#include "self.hpp"
25#include "static.hpp"
26#include <algorithm>
27
28#define __XTD_ARRAY_INTERNAL__
30#include "basic_array.hpp"
31#undef __XTD_ARRAY_INTERNAL__
32
34namespace xtd {
63 template<class type_t, xtd::size rank_, class allocator_t>
64 class array : public basic_array<type_t, allocator_t> {
65 public:
67
70 using value_type = type_t;
96
98
105 array() = default;
108 array(const array& array) : xtd::basic_array<type_t, allocator_t>(array) {}
111 array(array&& array) = default;
118 array(const array<xtd::size, 1>& lengths) : xtd::basic_array<type_t, allocator_t>(lengths) {}
125 array(const array<xtd::size, 1>& lengths, const type_t& value) : xtd::basic_array<type_t, allocator_t>(lengths, value) {}
127
129
136 xtd::size rank() const noexcept override {return rank_;}
138
140
144 xtd::string to_string() const noexcept override;
146
148
153 array& operator=(const array&) = default;
157 array& operator=(array&&) = default;
159
160 private:
161 friend class array<>;
162 array(const array<xtd::size>& lengths, bool) : basic_array<type_t, allocator_t>(lengths) {}
163 };
164}
165
166#define __XTD_ARRAY_INTERNAL__
167#include "array_1.hpp"
168#include "array_2.hpp"
169#include "array_3.hpp"
170#include "array_static.hpp"
171#include "array_.hpp"
172#undef __XTD_ARRAY_INTERNAL__
173#define __XTD_CORE_INTERNAL__
175#undef __XTD_CORE_INTERNAL__
176
178template<class source_t>
179auto xtd::linq::enumerable::chunk(const ienumerable<source_t>& source, size_t size) {
181 auto chunks = __opaque_xtd_linq_enumerable_collection__<xtd::array<source_t>> {};
182 chunks = __opaque_xtd_linq_enumerable_collection__<xtd::array<source_t>> {};
183 auto chunk = std::vector<source_t> {};
184 for (auto index = size_t {0}; const auto& item : source) {
185 chunk.push_back(item);
186 if (++index % size == 0) {
187 chunks.items.push_back(chunk);
188 chunk = std::vector<source_t> {};
189 }
190 }
191 if (chunk.size() != 0) chunks.items.push_back(chunk);
192
193 return chunks;
194}
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.
Contains xtd::byte type.
array(const array< xtd::size, 1 > &lengths)
Initializes a new instance of the array class with lengths for each rank specified.
Definition array.hpp:118
typename xtd::basic_array< xtd::string, allocator_t >::difference_type difference_type
Definition array.hpp:78
typename xtd::basic_array< xtd::string, allocator_t >::const_pointer const_pointer
Definition array.hpp:86
array(const array< xtd::size, 1 > &lengths, const type_t &value)
Initializes a new instance of the array class with lengths for each rank specified.
Definition array.hpp:125
typename xtd::basic_array< xtd::string, allocator_t >::const_reference const_reference
Definition array.hpp:82
xtd::size rank() const noexcept override
Gets the rank (number of dimensions) of the array.
Definition array.hpp:136
typename xtd::basic_array< xtd::string, allocator_t >::size_type size_type
Definition array.hpp:76
typename xtd::basic_array< xtd::string, allocator_t >::pointer pointer
Definition array.hpp:84
array()=default
Initializes a new instance of the array class that is empty.
xtd::string value_type
Definition array.hpp:70
typename xtd::basic_array< xtd::string, allocator_t >::reverse_iterator reverse_iterator
Definition array.hpp:92
typename xtd::basic_array< xtd::string, allocator_t >::iterator iterator
Definition array.hpp:88
array(const array &array)
Copy constructor with specified array.
Definition array.hpp:108
typename xtd::basic_array< xtd::string, allocator_t >::const_iterator const_iterator
Definition array.hpp:90
typename xtd::basic_array< xtd::string, allocator_t >::allocator_type allocator_type
Definition array.hpp:72
typename xtd::basic_array< xtd::string, allocator_t >::base_type base_type
Definition array.hpp:74
typename xtd::basic_array< xtd::string, allocator_t >::reference reference
Definition array.hpp:80
array(array &&array)=default
Move constructor with specified array.
typename xtd::basic_array< xtd::string, allocator_t >::const_reverse_iterator const_reverse_iterator
Definition array.hpp:94
xtd::string to_string() const noexcept override
Returns a xtd::string that represents the current object.
const value_type & const_reference
Represents the const reference of array value type.
Definition basic_array.hpp:45
xtd::collections::generic::helpers::allocator< value_type > allocator_type
Represents the array allocator type.
Definition basic_array.hpp:35
typename xtd::collections::generic::ienumerable< type_t >::const_iterator const_iterator
Represents the const iterator of array value type.
Definition basic_array.hpp:53
xtd::ptrdiff difference_type
Represents the array difference type (usually xtd::ptrdiff).
Definition basic_array.hpp:41
const value_type * const_pointer
Represents the const pointer of array value type.
Definition basic_array.hpp:49
typename xtd::collections::generic::helpers::raw_array< value_type >::reverse_iterator reverse_iterator
Represents the reverse iterator of array value type.
Definition basic_array.hpp:55
value_type * pointer
Represents the pointer of array value type.
Definition basic_array.hpp:47
value_type & reference
Represents the reference of array value type.
Definition basic_array.hpp:43
typename xtd::collections::generic::helpers::raw_array< value_type, allocator_type >::base_type base_type
Represents the array base type.
Definition basic_array.hpp:37
typename xtd::collections::generic::helpers::raw_array< value_type >::const_reverse_iterator const_reverse_iterator
Represents the const reverse iterator of array value type.
Definition basic_array.hpp:57
typename xtd::collections::generic::ienumerable< type_t >::iterator iterator
Represents the iterator of array value type.
Definition basic_array.hpp:51
xtd::size size_type
Represents the array size type (usually xtd::size).
Definition basic_array.hpp:39
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
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
Contains xtd::iequatable interface.
Contains xtd::int64 type.
Contains xtd::collections::generic::helpers::lesser struct.
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 xtd::collections::generic::helpers::raw_array class.
Contains self_ keyword.
Contains xtd::static_object class.
Contains xtd::helpers::throw_helper class.