template<typename type_t,
xtd::usize extent>
class xtd::span< type_t, extent >
Represents a non-owning view over a contiguous sequence of objects.
- Definition
template<typename type_t, xtd::usize extent = dynamic_extent>
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:40
constexpr span()
Creates an empty xtd::span whose xtd::span::data is null and xtd::span::size is 0.
Definition span.hpp:90
- Header
-
- Namespace
- xtd
- Library
- xtd.core
- Examples
- Create a span from memory.
#include <xtd/xtd>
auto main() -> int {
auto memory_pointer = new byte[100];
auto memory_span =
span(memory_pointer, 100);
for (auto ctr = 0_z; ctr < memory_span.length(); ++ctr)
memory_span[ctr] =
data++;
auto array_sum = 0;
for (auto value : memory_span)
array_sum += value;
delete[] memory_pointer;
}
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition span.hpp:222
constexpr auto data() const noexcept -> const_pointer
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:197
Create a span over an array.
#include <xtd/xtd>
auto main() -> int {
auto array_span =
span(bytes);
for (auto ctr = 0_z; ctr < array_span.length(); ++ctr)
array_span[ctr] =
data++;
auto array_sum = 0;
for (auto value : bytes)
array_sum += value;
}
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
|
| template<xtd::usize count = 0> |
| constexpr | span () |
| | Creates an empty xtd::span whose xtd::span::data is null and xtd::span::size is 0.
|
| template<typename iterator_t> |
| constexpr | span (iterator_t first, iterator_t last) |
| | Creates an xtd::span with specified iterators.
|
| template<xtd::usize len> |
| constexpr | span (element_type(&array)[len]) noexcept |
| | Creates an xtd::span with specified native array.
|
| template<typename array_type_t, xtd::usize len> |
| constexpr | span (const std::array< array_type_t, len > &array) noexcept |
| | Creates an xtd::span with specified std::array.
|
| template<typename array_type_t, xtd::usize len> |
| constexpr | span (std::array< array_type_t, len > &array) noexcept |
| | Creates an xtd::span with specified std::array.
|
| template<typename array_type_t> |
| constexpr | span (const xtd::array< array_type_t > &items) |
| | Creates an xtd::span with specified collection and count.
|
| template<typename array_type_t> |
| constexpr | span (xtd::array< array_type_t > &items) |
| | Creates an xtd::span with specified collection and count.
|
| template<typename range_t> |
| constexpr | span (range_t &&range) noexcept |
| | Creates an xtd::span with specified range.
|
| constexpr | span (std::initializer_list< type_t > items) noexcept |
| | Creates an xtd::span with specified initializer list.
|
| template<typename collection_t> |
| constexpr | span (collection_t &items, size_type length) |
| | Creates an xtd::span with specified collection and count.
|
| template<typename collection_t> |
| constexpr | span (collection_t &items, size_type start, size_type length) |
| | Creates an xtd::span with specified collection, offest and count.
|
| constexpr | span (type_t *const data, size_type length) |
| | Creates an xtd::span with specified data pointer and count.
|
| template<typename collection_t> |
| constexpr | span (collection_t &items, const xtd::range &range) |
| | Creates an xtd::span with specified collection, and range.
|
|
| auto | clear () noexcept -> void |
| | Clears the contents of this xtd::span <type> object.
|
| template<xtd::usize length> |
| auto | copy_to (span< type_t, length > &destination) const -> void |
| | Copies the contents of this xtd::span <type_t> into a destination xtd:span <type_t>.
|
| auto | equals (const object &obj) const noexcept -> bool override |
| | Determines whether the specified object is equal to the current object.
|
| auto | equals (const span &rhs) const noexcept -> bool override |
| | Indicates whether the current object is equal to another object of the same type.
|
| auto | fill (const type_t &value) -> void |
| | Fills the elements of this span with a specified value.
|
| template<xtd::usize count> |
| auto | first () const -> span< type_t, count > |
| | Obtains a subspan consisting of the first count elements of the sequence.
|
| auto | first (xtd::usize count) const -> span< type_t > |
| | Obtains a subspan consisting of the first count elements of the sequence.
|
| auto | get_enumerator () const -> xtd::collections::generic::enumerator< type_t > override |
| | Returns an enumerator that iterates through a collection.
|
| auto | get_hash_code () const noexcept -> xtd::usize override |
| | Serves as a hash function for a particular type.
|
| template<xtd::usize count> |
| auto | last () const -> span< type_t, count > |
| | Obtains a subspan consisting of the last N elements of the sequence.
|
| auto | last (xtd::usize count) const -> span< type_t > |
| | Obtains a subspan consisting of the last N elements of the sequence.
|
| template<xtd::usize start, size_type lenght = xtd::dynamic_extent> |
| auto | slice () const -> span< type_t > |
| | Forms a slice out of the current span starting at a specified index for a specified length.
|
| auto | slice (size_type start) const -> span< type_t > |
| | Forms a slice out of the current span that begins at a specified index.
|
| auto | slice (size_type start, size_type length) const -> span< type_t > |
| | Forms a slice out of the current span starting at a specified index for a specified length.
|
| template<xtd::usize offset, size_type count = xtd::dynamic_extent> |
| auto | subspan () const -> span< type_t > |
| | Forms a subspan of the current span starting at a specified index for a specified length.
|
| auto | subspan (size_type offset, size_type count=xtd::dynamic_extent) const -> span< type_t > |
| | Forms a subspan of the current span starting at a specified index for a specified length.
|
| auto | to_array () const noexcept -> xtd::array< value_type > |
| | Copies the contents of this span into a new array.
|
| auto | to_string () const noexcept -> xtd::string override |
| | Returns the string representation of this xtd::span <type_t> object.
|
| template<xtd::usize length> |
| auto | try_copy_to (span< type_t, length > &destination) const noexcept -> bool |
| | Attempts to copy the current xtd::span <type_t> to a destination xtd::span <type_t> and returns a value that indicates whether the copy operation succeeded.
|
|
| 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 | value_type |
| | Represents the ienumerable value type.
|
| using | ienumerable |
| | Represents the ienumerable value type.
|
| using | list |
| | Represents the list value type.
|
| | object ()=default |
| | Create a new instance of the ultimate base class object.
|
| 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 | equals (const type_t &) const noexcept -> bool=0 |
| | Indicates whether the current object is equal to another object of the same type.
|
| 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 (func_t &&funcfunc) const -> type_t |
| | Applies an accumulator function over a sequence.
|
| auto | all (predicate_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 (element_t &&element) const noexcept -> xtd::collections::generic::enumerable_generator< type_t > |
| | 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 value_t values.
|
| auto | cast () const noexcept -> xtd::collections::generic::enumerable_generator< result_t > |
| | Casts the elements of an xtd::collections::generic::ienumerable to the specified type.
|
| auto | chunk (xtd::usize size) const -> xtd::collections::generic::enumerable_generator< xtd::array< type_t > > |
| | Splits the elements of a sequence into chunks of size at most size.
|
| auto | concat (second_t &&second) const noexcept -> xtd::collections::generic::enumerable_generator< type_t > |
| | Concatenates two sequences.
|
| auto | contains (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 (key_selector_t &&key_selector) const noexcept |
| | Returns the count of elements in the current sequence grouped by key.
|
| auto | default_if_empty () const noexcept -> xtd::collections::generic::enumerable_generator< type_t > |
| | 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 -> xtd::collections::generic::enumerable_generator< type_t > |
| | Returns distinct elements from a sequence by using the default equality comparer to compare values.
|
| auto | first_or_default (predicate_t &&predicatepredicate, 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 | max () const -> type_t |
| | Returns the maximum value in a sequence of xtd::numeric values.
|
| auto | min () const -> type_t |
| | Returns the minimum value in a sequence of xtd::numeric values.
|
| auto | order () const -> xtd::collections::generic::enumerable_generator< type_t > |
| | 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 | shuffle () const -> xtd::collections::generic::enumerable_generator< type_t > |
| | Shuffles the order of the elements of a sequence.
|
| auto | skip (xtd::usize count) -> xtd::collections::generic::enumerable_generator< type_t > |
| | Bypasses a specified number of elements in a sequence and then returns the remaining elements.
|
| auto | skip_while (auto &&predicatepredicate) -> xtd::collections::generic::enumerable_generator< type_t > |
| | Bypasses elements in a sequence as long as a specified condition is true and then returns the remaining elements.
|
| auto | take (xtd::usize count) -> xtd::collections::generic::enumerable_generator< type_t > |
| | Returns a specified number of contiguous elements from the start of a sequence.
|
| auto | take_while (auto &&predicatepredicate) -> xtd::collections::generic::enumerable_generator< type_t > |
| | Returns elements from a sequence as long as a specified condition is true, and then skips the remaining elements.
|
| auto | to_array () const -> xtd::array< type_t > |
| | Creates a xtd::array <type_t> from an xtd::collections::generic::ienumerable <type_t>.
|
| auto | to_list () const -> 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.
|
| 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.
|