xtd 0.2.0
array_static.hpp
Go to the documentation of this file.
1
4
5#if !defined(__XTD_ARRAY_INTERNAL__)
6#error "Do not include this file: Internal use only. Include <xtd/array> or <xtd/array.h> instead."
7#endif
8
11
13namespace xtd {
16 template<class type_t>
18 }
20
49 template<>
50 class array<> static_ {
51 public:
53
56
58
69 template<class type_t, class allocator_t>
71
90 template<class type_t, class allocator_t>
92
114 template<class type_t, class allocator_t>
117 typename std::vector<type_t>::const_iterator first = array.array.begin();
118 typename std::vector<type_t>::const_iterator last = array.array.begin();
119 std::advance(first, index);
120 std::advance(last, index + count);
121 typename std::vector<type_t>::const_iterator position = std::lower_bound(first, last, value, xtd::array<type_t>::comparer(&comparer));
122
123 if (position != array.array.end() && !comparer->Compare(value, *position))
124 return (int32)std::distance(array.array.begin(), position);
125 return (int32)~std::distance(array.array.begin(), position);
126 }
127
143 template<class type_t, class allocator_t>
145
165 template<class type_t, class allocator_t>
166 static xtd::size binary_search(const array<type_t, 1, allocator_t>& array, const type_t& value, const xtd::collections::generic::icomparer<type_t>& comparer) {return binary_search(array, 0, array.Length, value, comparer);}
167
170 template<class type_t, xtd::size rank, class allocator_t>
172 clear(array, 0, array.data_->items.size());
173 }
174
183 template<class type_t, xtd::size rank, class allocator_t>
186 for (auto i = xtd::size {}; i < length; ++i)
187 array.data_->items[index + i] = type_t {};
188 }
189
195 template<class source_type_t, xtd::size source_rank, class source_allocator_t, class destination_type_t, xtd::size destination_rank, class destination_allocator_t>
197 copy(source_array, 0, destination_array, 0, length);
198 }
199
207 template<class source_type_t, xtd::size source_rank, class source_allocator_t, class destination_type_t, xtd::size destination_rank, class destination_allocator_t>
208 static void copy(const array<source_type_t, source_rank, source_allocator_t>& source_array, xtd::size source_index, const array<destination_type_t, destination_rank, destination_allocator_t>& destination_array, xtd::size destination_index, xtd::size length); // defined in as.hpp file
209
211 };
212}
static void copy(const array< source_type_t, source_rank, source_allocator_t > &source_array, const array< destination_type_t, destination_rank, destination_allocator_t > &destination_array, xtd::size length)
Copies a range of elements from an xtd::array starting at the first element and pastes them into anot...
Definition array_static.hpp:196
static xtd::size binary_search(const array< type_t, 1, allocator_t > &array, xtd::size index, xtd::size count, const type_t &value, const xtd::collections::generic::icomparer< type_t > &comparer)
Searches a range of elements in a one-dimensional sorted array for a value, using the specified xtd::...
Definition array_static.hpp:115
static xtd::size binary_search(const array< type_t, 1, allocator_t > &array, const type_t &value, const xtd::collections::generic::icomparer< type_t > &comparer)
Searches a range of elements in a one-dimensional sorted array for a value, using the specified xtd::...
Definition array_static.hpp:166
static xtd::size binary_search(const array< type_t, 1, allocator_t > &array, const type_t &value)
Searches an entire one-dimensional sorted array for a specific element, using the xtd::icomparable in...
Definition array_static.hpp:144
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.
static void copy(const array< source_type_t, source_rank, source_allocator_t > &source_array, xtd::size source_index, const array< destination_type_t, destination_rank, destination_allocator_t > &destination_array, xtd::size destination_index, xtd::size length)
Copies a range of elements from an xtd::array starting at the specified source index and pastes them ...
static void clear(const array< type_t, rank, allocator_t > &array, xtd::size index, xtd::size length)
Sets a range of elements in an array to the default value of each element type.
Definition array_static.hpp:184
static int32 binary_search(const array< type_t, 1, allocator_t > &array, int32 index, int32 length, const type_t &value)
Searches a range of elements in a one-dimensional sorted array for a value, using the xtd::icomparabl...
Definition array_static.hpp:91
static void clear(const array< type_t, rank, allocator_t > &array)
Clears the contents of an array.
Definition array_static.hpp:171
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
array()=default
size_type count() const noexcept override
Definition basic_array.hpp:151
virtual size_type length() const noexcept
Definition basic_array.hpp:209
static const comparer< xtd::any_object > default_comparer
Definition comparer.hpp:50
Exposes a method that compares two objects.
Definition icomparer.hpp:30
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.
Contains xtd::collections::generic::comparer <type_t> class.
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:59
#define static_
This keyword is use to represent a static object. A static object can't be instantiated (constructors...
Definition static.hpp:37
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
@ i
The I key.
Definition console_key.hpp:104
Contains classes that can be used as collections in the object model of a reusable library....
Definition read_only_collection.hpp:15
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307
Contains xtd::helpers::exception_case enum class.