template<typename type_t,
xtd::usize rank_, typename allocator_t>
class xtd::array< type_t, rank_, allocator_t >
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the base class for all arrays.
- Definition
template<typename type_t, xtd::usize rank_, typename allocator_t>
Base object that represent array.
Definition basic_array.hpp:27
- Header
-
- Namespace
- xtd
- Library
- xtd.core
- Examples
- The following code example demonstrates different methods to create an array.
- Examples
- The following code example creates and initializes an Array and displays its properties and its elements.
#include <xtd/xtd>
auto print_values(const array<int>& my_arr) {
for (auto i : my_arr)
}
for (auto o : my_arr)
}
auto main() -> int {
auto my_int_array = array<int> {1, 2, 3, 4, 5};
auto my_obj_array = array<any_object> {26, 27, 28, 29, 30};
console::write_line("Initially,");
console::write("integer array:");
print_values(my_int_array);
console::write("Object array: ");
print_values(my_obj_array);
array<>::copy(my_int_array, my_obj_array, 2);
console::write_line("\nAfter copying the first two elements of the integer array to the Object array,");
console::write("integer array:");
print_values(my_int_array);
console::write("Object array: ");
print_values(my_obj_array);
xtd::array<>::copy(my_obj_array, my_obj_array.get_upper_bound(0) - 1, my_int_array, my_int_array.get_upper_bound(0) - 1, 2);
console::write_line("\nAfter copying the last two elements of the Object array to the integer array,");
console::write("integer array:");
print_values(my_int_array);
console::write("Object array: ");
print_values(my_obj_array);
}
static auto 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) -> void
Copies a range of elements from an xtd::array starting at the first element and pastes them into anot...
Definition array_static.hpp:239
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
static auto write(arg_t &&value) -> void
Writes the text representation of the specified value to the standard output stream.
Definition console.hpp:480
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
- Examples
- date_time_format_info.cpp, date_time_now.cpp, form_paint.cpp, graphics.cpp, and ienumerable.cpp.
|
| using | value_type |
| | Represents the array value type.
|
| using | allocator_type |
| | Represents the array allocator type.
|
| using | base_type |
| | Represents the array base type.
|
| using | size_type |
| | Represents the array size type (usually xtd::usize).
|
| using | difference_type |
| | Represents the array difference type (usually xtd::ptrdiff).
|
| using | reference |
| | Represents the reference of array value type.
|
| using | const_reference |
| | Represents the const reference of array value type.
|
| using | pointer |
| | Represents the pointer of array value type.
|
| using | const_pointer |
| | Represents the const pointer of array value type.
|
| using | iterator |
| | Represents the iterator of array value type.
|
| using | const_iterator |
| | Represents the const iterator of array value type.
|
| using | reverse_iterator |
| | Represents the reverse iterator of array value type.
|
| using | const_reverse_iterator |
| | Represents the const reverse iterator of array value type.
|
| using | value_type |
| | Represents the xtd::collections::generic::icollection value type.
|
| using | value_type |
| | Represents the xtd::collections::generic::ienumerable value type.
|
| using | iterator |
| | Represents the iterator of xtd::collections::generic::ienumerable value type.
|
| using | const_iterator |
| | Represents the const iterator of xtd::collections::generic::ienumerable value type.
|
| using | iterator |
| | Represents the iterator of enumerable value type.
|
| using | const_iterator |
| | Represents the const iterator of enumerable value type.
|
| using | enumerable_type |
| | Represents the ienumerable enumerable type.
|
| using | source_type |
| | Represents the ienumerable source type.
|
| using | ienumerable |
| | Represents the ienumerable value type.
|
| using | list |
| | Represents the list value type.
|
| static constexpr xtd::usize | npos |
| | Represents a value that is not a valid position in a collection.
|
| static constexpr xtd::usize | bpos |
| | Represents the index of the first valid element in a collection.
|
| static constexpr xtd::usize | epos |
| | Represents the index of the last valid element in a collection.
|
| auto | count () const noexcept -> size_type override |
| | Gets the number of elements contained in the xtd::array <type_t>.
|
| virtual auto | data () noexcept -> pointer |
| | Returns pointer to the underlying array serving as element storage.
|
| auto | is_fixed_size () const noexcept -> bool override |
| | Gets a value indicating whether the xtd::collections::generic::ilist <type_t> has a fixed size.
|
| auto | is_read_only () const noexcept -> bool override |
| | Gets a value indicating whether the xtd::collections::generic::icollection <type_t> is read-only.
|
| auto | is_synchronized () const noexcept -> bool override |
| | Gets a value indicating whether access to the xtd::collections::generic::icollection <type_t> is synchronized (thread safe).
|
| virtual auto | items () const noexcept -> const base_type & |
| | Returns the underlying base type items.
|
| virtual auto | length () const noexcept -> size_type |
| | Gets a size that represents the total number of elements in all the dimensions of the array.
|
| virtual auto | long_length () -> xtd::int64 |
| | Gets a 64-bit integer that represents the total number of elements in all the dimensions of the array.
|
| virtual auto | max_length () const noexcept -> size_type |
| | Returns the maximum number of elements the container is able to hold due to system or library implementation limitations, i.e. std::distance(xtd::array::begin(), xtd::array::end()) for the largest container.
|
| auto | sync_root () const noexcept -> const xtd::object &override |
| | Gets an object that can be used to synchronize access to the the xtd::collections::generic::icollection <type_t>.
|
| auto | contains (const type_t &value) const noexcept -> bool override |
| | Determines whether an element is in the array.
|
| auto | copy_to (xtd::array< type_t > &array) const -> void |
| | Copies the entire xtd::array <type_t> to a compatible one-dimensional array.
|
| auto | equals (const object &obj) const noexcept -> bool override |
| | Determines whether this instance and a specified object, which must also be a xtd::basic_array object, have the same value.
|
| virtual auto | fill (const value_type &value) noexcept -> void |
| | Assigns the value to all elements in the container.
|
| auto | get_enumerator () const noexcept -> xtd::collections::generic::enumerator< value_type > override |
| | Returns an enumerator that iterates through a collection.
|
| constexpr auto | get_length (size_type dimension) const -> size_type |
| | Gets the total number of elements in all the dimensions of the array.
|
| auto | get_lengths () const -> xtd::array< size_type, 1 > |
| | Gets an array of the number of elements of all the dimensions of the array.
|
| constexpr auto | get_long_length (size_type dimension) const -> xtd::int64 |
| | Gets a 64-bit integer that represents the total number of elements in all the dimensions of the array.
|
| constexpr auto | get_lower_bound (size_type dimension) const -> size_type |
| | Gets the lower bound of the specified dimension in the array.
|
| constexpr auto | get_upper_bound (size_type dimension) const -> size_type |
| | Gets the upper bound of the specified dimension in the array.
|
| auto | get_value (const xtd::array< size_type > &indexes) const -> const value_type & |
| | Gets the value at the specified position in the multidimensional array. The indexes are specified as 32-bit integers array.
|
| auto | index_of (const type_t &value) const noexcept -> size_type override |
| | Determines the index of a specific item in the xtd::array <type_t>.
|
| auto | set_value (const type_t &value, const xtd::array< size_type > &indexes) -> void |
| | Determines the index of a specific item in the xtd::basic_array <type_t>.
|
| auto | sort () -> basic_array< type_t > & |
| | Sorts the elements in the entire xtd::basic_array <type_t> using the default comparer.
|
| auto | to_string () const noexcept -> xtd::string override |
| | Returns a xtd::string that represents the current object.
|
| auto | operator= (const basic_array &other) -> basic_array & |
| | Copy assignment operator. Replaces the contents with a copy of the contents of other.
|
| auto | operator[] (size_type index) const -> const_reference override |
| | Returns a reference to the element at specified location index.
|
| | operator const base_type & () const noexcept |
| | Returns a reference to the underlying base type.
|
| | operator base_type & () noexcept |
| | Returns a reference to the underlying base type.
|
| auto | operator() (const xtd::array< size_type > &indexes) -> type_t & |
| | Gets the value at the specified position in the multidimensional array. The indexes are specified as a 32-bit integer array.
|
| | object ()=default |
| | Create a new instance of the ultimate base class object.
|
| virtual auto | get_hash_code () const noexcept -> xtd::usize |
| | Serves as a hash function for a particular type.
|
| virtual auto | get_type () const noexcept -> type_object |
| | Gets the type of the current instance.
|
| template<typename object_t> |
| auto | memberwise_clone () const -> xtd::unique_ptr_object< object_t > |
| | Creates a shallow copy of the current object.
|
| virtual auto | copy_to (xtd::array< type_t > &array, xtd::usize array_index) const -> void=0 |
| | Copies the elements of the xtd::collections::generic::icollection <type_t> to an xtd::array, starting at a particular xtd::array index.
|
| virtual auto | operator[] (xtd::usize index) -> type_t &=0 |
| | Sets the element at the specified index.
|
| virtual auto | begin () const -> const_iterator |
| | Returns an iterator to the first element of the enumerable.
|
| virtual auto | cbegin () const -> const_iterator |
| | Returns an iterator to the first element of the enumerable.
|
| virtual auto | cend () const -> const_iterator |
| | Returns an iterator to the element following the last element of the enumerable.
|
| virtual auto | end () const -> const_iterator |
| | Returns an iterator to the element following the last element of the enumerable.
|
| auto | aggregate (const std::function< type_t(const type_t &, const type_t &)> &funcfunc) const -> type_t |
| | Applies an accumulator function over a sequence.
|
| auto | all (const std::function< bool(const type_t &)> &predicatepredicate) const -> bool |
| | Determines whether all elements of a sequence satisfy a condition.
|
| auto | any () const noexcept -> bool |
| | Determines whether a sequence contains any elements.
|
| auto | append (const type_t &element) const noexcept |
| | Appends a value to the end of the sequence.
|
| auto | as_enumerable () const noexcept |
| | Returns the input typed as xtd::collections::generic::ienumerable <type_t>.
|
| auto | average () const noexcept |
| | Computes the average of a sequence of source_t values.
|
| auto | cast () const noexcept |
| | Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
|
| auto | chunk (xtd::usize size) const |
| | Splits the elements of a sequence into chunks of size at most size.
|
| auto | concat (const ienumerable< type_t > &second) const noexcept |
| | Concatenates two sequences.
|
| auto | contains (const type_t &value) const noexcept -> bool |
| | Determines whether a sequence contains a specified element by using the default equality comparer.
|
| auto | count () const noexcept -> xtd::usize |
| | Returns the number of elements in current sequence.
|
| auto | count_by (const std::function< key_t(const type_t &)> &key_selector) const noexcept |
| | Returns the count of elements in the current sequence grouped by key.
|
| auto | default_if_empty () const noexcept |
| | Returns the elements of the specified sequence or the type parameter's default value in a singleton collection if the current sequence is empty.
|
| auto | distinct () const noexcept |
| | Returns distinct elements from a sequence by using the default equality comparer to compare values.
|
| auto | first_or_default (const std::function< bool(const type_t &)> &predicatepredicate, const type_t &default_value) const noexcept -> type_t |
| | Returns the first element of the sequence that satisfies a condition, or a specified default value if no such element is found.
|
| auto | order () const |
| | Sorts the elements of a sequence in ascending order.
|
| auto | order_by (const std::function< type_t(const type_t &)> &key_selector) const |
| | Sorts the elements of a sequence in ascending order according to a key.
|
| auto | order_by_descending (const std::function< key_t(const type_t &)> &key_selector) const |
| | Sorts the elements of a sequence in descending order according to a key.
|
| auto | select (auto &&selector) const |
| | Projects each element of a sequence into a new form.
|
| auto | to_array () const noexcept -> xtd::array< type_t > |
| | Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
|
| auto | to_list () const noexcept -> xtd::collections::generic::list< type_t > |
| | Creates a xtd::collections::generic::list <type_t> from an xtd::collections::generic::ienumerable <type_t>.
|
| auto | where (auto &&predicatepredicate) const |
| | Filters a sequence of values based on a predicate.
|
| virtual auto | empty () const noexcept -> bool |
| | Checks whether the container is empty.
|
| virtual auto | size () const noexcept -> xtd::usize |
| | Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
|
| virtual auto | operator<< (const type_t &item) -> icollection< type_t > & |
| | The shift left operator adds an item to the xtd::collections::generic::icollection <type_t>.
|
| virtual auto | operator>> (const type_t &item) -> icollection< type_t > & |
| | The shift right operator removes the first occurrence of a specific object from the xtd::collections::generic::icollection <type_t>.
|
| virtual auto | equals (const type_t &) const noexcept -> bool=0 |
| | Indicates whether the current object is equal to another object of the same type.
|
| template<typename object_a_t, typename object_b_t> |
| static auto | equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| | Determines whether the specified object instances are considered equal.
|
| template<typename object_a_t, typename object_b_t> |
| static auto | reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept -> bool |
| | Determines whether the specified object instances are the same instance.
|
| static auto | to_const_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator |
| | Converts source iterator to target iterator.
|
| static auto | to_iterator (typename source_collection_t::const_iterator &value, const source_collection_t &source_collection, const target_collection_t &target_collection) noexcept -> typename target_collection_t::const_iterator |
| | Converts source iterator to target iterator.
|
| | abstract_object ()=default |
| | Initializes a new instance of the xtd::abstract_object class.
|