xtd 0.2.0
Loading...
Searching...
No Matches
xtd::fixed_array< type_t, len > Class Template Reference
Inheritance diagram for xtd::fixed_array< type_t, len >:
xtd::object xtd::collections::generic::ienumerable< type_t > xtd::iequatable< fixed_array< type_t, len > > xtd::interface xtd::collections::generic::ienumerable_abstract xtd::collections::generic::extensions::enumerable_iterators< type_t, xtd::collections::generic::ienumerable< type_t > > xtd::collections::generic::extensions::enumerable< ienumerable< type_t >, type_t > xtd::interface xtd::extensions::equality_operators< type_t, iequatable< type_t > >

Definition

template<typename type_t, xtd::usize len>
class xtd::fixed_array< type_t, len >

Represents a fixed array class.

Header
#include <xtd/fixed_array>
Namespace
xtd
Library
xtd.core

Public Aliases

using value_type
 Represents the array value type.
using base_type
 Represents the array base type.
using const_base_type
 Represents the const array base type.
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 size_type
 Represents the array size type (usually xtd::usize).
using difference_type
 Represents the array difference type (usually xtd::ptrdiff).

Public Constructors

 fixed_array ()=default
 Initializes a new instance of the fixed_array class that is empty.
 fixed_array (std::initializer_list< type_t > items)
 Initializes a new instance of the fixed_array class with specified initializer list.

Public Properties

auto count () const noexcept -> size_type
 Gets the number of elements contained in the xtd::fixed_array <type_t>.
auto data () const noexcept -> const_pointer
 Returns pointer to the underlying array serving as element storage.
auto data () noexcept -> pointer
 Returns pointer to the underlying array serving as element storage.
virtual auto empty () const noexcept -> bool
 Checks if the container has no elements, i.e. whether xtd::array::begin() == xtd::array::end().
virtual auto items () const noexcept -> const_base_type
 Returns the underlying base type items.
virtual auto items () noexcept -> 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.
auto size () const noexcept -> size_type
 Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(), xtd::array::end()).

Public Methods

auto clear () noexcept -> void
 Clears the contents of this xtd::span <type> object.
auto contains (const value_type &value) const noexcept -> bool
 Determines whether an element is in the array.
auto copy_to (xtd::array< value_type > &array) const -> void
 Copies the entire xtd::array <type_t> to a compatible one-dimensional array.
auto copy_to (xtd::array< value_type > &array, size_type array_index) const -> void
 Copies the elements of the xtd::array <type_t> to an xtd::array, starting at a particular xtd::array index.
auto copy_to (const size_type index, xtd::array< value_type > &array, size_type array_index) const -> void
 Copies the elements of the xtd::array <type_t> from a specified index to an xtd::array, starting at a particular xtd::array index.
auto copy_to (const size_type index, xtd::array< value_type > &array, size_type array_index, size_type count) const -> void
 Copies the elements of the xtd::array <type_t> from a specified index to an xtd::array, starting at a particular xtd::array index.
auto equals (const object &obj) const noexcept -> bool override
 Determines whether this instance and a specified object, which must also be a xtd::fixed_array object, have the same value.
auto equals (const fixed_array &rhs) const noexcept -> bool override
 Determines whether this instance and another specified xtd::fixed_array object have the same value.
auto fill (const value_type &value) -> void
 Fills the elements of this span with a specified value.
auto get_enumerator () const -> xtd::collections::generic::enumerator< value_type > override
 Returns an enumerator that iterates through a collection.
auto index_of (const value_type &value) const noexcept -> size_type
 Determines the index of a specific item in the xtd::array <type_t>.
auto index_of (const value_type &value, size_type index) const -> size_type
 Determines the index of a specific item in the xtd::fixed_array <type_t>.
auto sort () -> fixed_array &
 Determines the index of a specific item in the xtd::fixed_array <type_t>.
template<typename comparison_t>
auto sort (comparison_t &&comparison) -> fixed_array &
 Sorts the elements in the entire xtd::fixed_array <type_t> using the specified xtd::comparison <type_t>.
auto sort (const xtd::collections::generic::icomparer< type_t > &comparer) -> fixed_array &
 Sorts the elements in the entire xtd::fixed_array <type_t> using the specified comparer.
auto sort (xtd::usize index, xtd::usize count, const xtd::collections::generic::icomparer< type_t > &comparer) -> fixed_array &
 Sorts the elements in a range of elements in xtd::fixed_array <type_t> using the specified comparer.
virtual auto to_array () const noexcept -> xtd::array< value_type >
 Copies the elements of the xtd::fixed_array <type_t> to a new array.
auto to_string () const noexcept -> xtd::string override
 Returns a xtd::string that represents the current object.

Public Operators

auto operator[] (size_type index) const -> const_reference
 Returns a reference to the element at specified location index.
auto operator[] (size_type index) -> reference
 Returns a reference to the element at specified location index.

Additional Inherited Members

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.
 object ()=default
 Create a new instance of the ultimate base class object.
virtual xtd::usize get_hash_code () const noexcept
 Serves as a hash function for a particular type.
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
template<typename object_t>
xtd::unique_ptr_object< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
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 &)> &func) const -> type_t
 Applies an accumulator function over a sequence.
auto all (const std::function< bool(const type_t &)> &predicate) 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 &)> &predicate, 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 &&predicate) const
 Filters a sequence of values based on a predicate.
virtual bool equals (const type_t &) const noexcept=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 bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
template<typename object_a_t, typename object_b_t>
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 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.

Member Typedef Documentation

◆ value_type

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::value_type

Represents the array value type.

◆ base_type

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::base_type

Represents the array base type.

◆ const_base_type

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::const_base_type

Represents the const array base type.

◆ reference

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::reference

Represents the reference of array value type.

◆ const_reference

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::const_reference

Represents the const reference of array value type.

◆ pointer

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::pointer

Represents the pointer of array value type.

◆ const_pointer

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::const_pointer

Represents the const pointer of array value type.

◆ size_type

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::size_type

Represents the array size type (usually xtd::usize).

◆ difference_type

template<typename type_t, xtd::usize len>
using xtd::fixed_array< type_t, len >::difference_type

Represents the array difference type (usually xtd::ptrdiff).

Constructor & Destructor Documentation

◆ fixed_array() [1/2]

template<typename type_t, xtd::usize len>
xtd::fixed_array< type_t, len >::fixed_array ( )
default

Initializes a new instance of the fixed_array class that is empty.

Remarks
The fixed_array class is not thread safe.

◆ fixed_array() [2/2]

template<typename type_t, xtd::usize len>
xtd::fixed_array< type_t, len >::fixed_array ( std::initializer_list< type_t > items)
inline

Initializes a new instance of the fixed_array class with specified initializer list.

Parameters
itemsThe initializer list to initialize the elements of the container with.
Remarks
The fixed_array class is not thread safe.

Member Function Documentation

◆ count()

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::count ( ) const -> size_type
inlinenodiscardnoexcept

Gets the number of elements contained in the xtd::fixed_array <type_t>.

Returns
The number of elements contained in the xtd::fixed_array <type_t>.

◆ data() [1/2]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::data ( ) const -> const_pointer
inlinenodiscardnoexcept

Returns pointer to the underlying array serving as element storage.

Returns
Pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal to the address of the first element.
Remarks
The pointer is such that range [xtd::array::data(), xtd::array::data() + xtd::array::size()) is always a valid range, even if the container is empty (xtd::array::data() is not dereferenceable in that case).

◆ data() [2/2]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::data ( ) -> pointer
inlinenodiscardnoexcept

Returns pointer to the underlying array serving as element storage.

Returns
Pointer to the underlying element storage. For non-empty containers, the returned pointer compares equal to the address of the first element.
Remarks
The pointer is such that range [xtd::array::data(), xtd::array::data() + xtd::array::size()) is always a valid range, even if the container is empty (xtd::array::data() is not dereferenceable in that case).

◆ empty()

template<typename type_t, xtd::usize len>
virtual auto xtd::fixed_array< type_t, len >::empty ( ) const -> bool
inlinenodiscardvirtualnoexcept

Checks if the container has no elements, i.e. whether xtd::array::begin() == xtd::array::end().

Returns
true if the container is empty, false otherwise.

◆ items() [1/2]

template<typename type_t, xtd::usize len>
virtual auto xtd::fixed_array< type_t, len >::items ( ) const -> const_base_type
inlinenodiscardvirtualnoexcept

Returns the underlying base type items.

Returns
The underlying base type items.

◆ items() [2/2]

template<typename type_t, xtd::usize len>
virtual auto xtd::fixed_array< type_t, len >::items ( ) -> base_type
inlinenodiscardvirtualnoexcept

Returns the underlying base type items.

Returns
The underlying base type items.

◆ length()

template<typename type_t, xtd::usize len>
virtual auto xtd::fixed_array< type_t, len >::length ( ) const -> size_type
inlinenodiscardvirtualnoexcept

Gets a size that represents the total number of elements in all the dimensions of the array.

Returns
A size that represents the total number of elements in all the dimensions of the array; zero if there are no elements in the array.
Remarks
Retrieving the value of this property is an O(1) operation.

◆ size()

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::size ( ) const -> size_type
inlinenodiscardnoexcept

Returns the number of elements in the container, i.e. std::distance(xtd::array::begin(), xtd::array::end()).

Returns
The number of elements in the container.

◆ clear()

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::clear ( ) -> void
inlinenoexcept

Clears the contents of this xtd::span <type> object.

Remarks
The xtd::span::clear method sets the items in the xtd::span <type_t> object to their default values. It does not remove items from the xtd::span <type_t>.

◆ contains()

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::contains ( const value_type & value) const -> bool
inlinenodiscardnoexcept

Determines whether an element is in the array.

Parameters
valueThe object to be added to the end of the array.

◆ copy_to() [1/4]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::copy_to ( xtd::array< value_type > & array) const -> void
inline

Copies the entire xtd::array <type_t> to a compatible one-dimensional array.

Parameters
arrayThe one-dimensional xtd::array that is the destination of the elements copied from ICollection. The xtd::array must have zero-based indexing.
Exceptions
xtd::argument_exceptionThe number of elements in the source xtd::array <type_t> is greater than the number of elements that the destination array can contain.

◆ copy_to() [2/4]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::copy_to ( xtd::array< value_type > & array,
size_type array_index ) const -> void
inline

Copies the elements of the xtd::array <type_t> to an xtd::array, starting at a particular xtd::array index.

Parameters
arrayThe one-dimensional xtd::array that is the destination of the elements copied from xtd::collections::generic::icollection <type_t>. The xtd::array must have zero-based indexing.
array_indexThe zero-based index in array at which copying begins.
Exceptions
xtd::argument_exceptionThe number of elements in the source xtd::array <type_t> is greater than the available space from `array_index` to the end of the destination `array`.

◆ copy_to() [3/4]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::copy_to ( const size_type index,
xtd::array< value_type > & array,
size_type array_index ) const -> void
inline

Copies the elements of the xtd::array <type_t> from a specified index to an xtd::array, starting at a particular xtd::array index.

Parameters
indexThe zero-based index in the source fixed_array at which copying begins.
arrayThe one-dimensional xtd::array that is the destination of the elements copied from xtd::collections::generic::icollection <type_t>. The xtd::array must have zero-based indexing.
array_indexThe zero-based index in array at which copying begins.
Exceptions
xtd::argument_exceptionThe number of elements in the source xtd::array <type_t> is greater than the available space from `array_index` to the end of the destination `array`.

◆ copy_to() [4/4]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::copy_to ( const size_type index,
xtd::array< value_type > & array,
size_type array_index,
size_type count ) const -> void
inline

Copies the elements of the xtd::array <type_t> from a specified index to an xtd::array, starting at a particular xtd::array index.

Parameters
indexThe zero-based index in the source fixed_array at which copying begins.
arrayThe one-dimensional xtd::array that is the destination of the elements copied from xtd::collections::generic::icollection <type_t>. The xtd::array must have zero-based indexing.
array_indexThe zero-based index in array at which copying begins.
countThe number of elements to copy.
Exceptions
xtd::argument_exceptionThe number of elements in the source xtd::array <type_t> is greater than the available space from `array_index` to the end of the destination `array`.

◆ equals() [1/2]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::equals ( const object & obj) const -> bool
inlinenodiscardoverridevirtualnoexcept

Determines whether this instance and a specified object, which must also be a xtd::fixed_array object, have the same value.

Parameters
objThe fixed_array to compare to this instance.
Returns
true if obj is a xtd::fixed_array and its value is the same as this instance; otherwise, false.

Reimplemented from xtd::object.

◆ equals() [2/2]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::equals ( const fixed_array< type_t, len > & rhs) const -> bool
inlinenodiscardoverridenoexcept

Determines whether this instance and another specified xtd::fixed_array object have the same value.

Parameters
valueThe fixed_array to compare to this instance.
Returns
true if the value of the value parameter is the same as the value of this instance; otherwise, false.
Remarks
This method performs an ordinal (case-sensitive) comparison.

◆ fill()

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::fill ( const value_type & value) -> void
inline

Fills the elements of this span with a specified value.

Parameters
valueThe value to assign to each element of the span.

◆ get_enumerator()

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::get_enumerator ( ) const -> xtd::collections::generic::enumerator< value_type >
inlinenodiscardoverridevirtual

Returns an enumerator that iterates through a collection.

Returns
An xtd::collections::generic::enumerator object that can be used to iterate through the collection.

Implements xtd::collections::generic::ienumerable< type_t >.

◆ index_of() [1/2]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::index_of ( const value_type & value) const -> size_type
inlinenodiscardnoexcept

Determines the index of a specific item in the xtd::array <type_t>.

Parameters
valueThe object to locate in the xtd::array.
Returns
The index of value if found in the array; otherwise, xtd::collections::generic::ilist::npos.

◆ index_of() [2/2]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::index_of ( const value_type & value,
size_type index ) const -> size_type
inlinenodiscard

Determines the index of a specific item in the xtd::fixed_array <type_t>.

Parameters
valueThe object to locate in the xtd::fixed_array <type_t>.
indexThe zero-based starting index of the search.
Returns
The index of value if found in the xtd::fixed_array; otherwise, xtd::collections::generic::ilist::npos.
Exceptions
xtd::argument_out_of_range_exception`index` is outside the range of valid indexes for the xtd::fixed_array <type_t>.

◆ sort() [1/4]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::sort ( ) -> fixed_array &
inline

Determines the index of a specific item in the xtd::fixed_array <type_t>.

Parameters
valueThe object to locate in the xtd::fixed_array <type_t>.
indexThe zero-based starting index of the search.
countThe number of elements in the section to search
Returns
The index of value if found in the xtd::fixed_array; otherwise, xtd::collections::generic::ilist::npos.
Exceptions
xtd::argument_out_of_range_exception`index` and `countù do not specify a valid section in the xtd::fixed_array <type_t>. */ [[nodiscard]] auto index_of(const value_type& value, size_type index, size_type count) const -> size_type { if (index > length() || index + count > length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range); for (auto increment = index; increment < (index + count); ++increment) if (xtd::collections::generic::helpers::equator<type_t> {}(items_[increment], value)) return increment; return xtd::npos; }

/** Sorts the elements in the entire xtd::fixed_array <type_t> using the default comparer.

Exceptions
xtd::invalid_operation_exceptionThe default comparer xtd::collections::generic::comparer::default_comparer cannot find an implementation of the xtd::icomparable <type_t> generic interface.
Examples
The xtd::fixed_array::binary_search method overload is then used to search for two strings that are not in the list, and the xtd::fixed_array::insert method is used to insert them. The return value of the xtd::fixed_array::binary_search method is gretaer than xtd::fixed_array::count in each case, because the strings are not in the list. Taking the bitwise complement of this negative number produces the index of the first element in the list that is larger than the search string, and inserting at this location preserves the sort order. The second search string is larger than any element in the list, so the insertion position is at the end of the list.
#include <xtd/xtd>
class example {
public:
static auto main() -> void {
auto dinosaurs = list<string> {};
dinosaurs.add("Pachycephalosaurus");
dinosaurs.add("Amargasaurus");
dinosaurs.add("Mamenchisaurus");
dinosaurs.add("Deinonychus");
for (auto dinosaur : dinosaurs)
dinosaurs.sort();
for (auto dinosaur : dinosaurs)
console::write_line("\nbinary_search and insert \"Coelophysis\":");
auto index = dinosaurs.binary_search("Coelophysis");
if (index > dinosaurs.count()) dinosaurs.insert(~index, "Coelophysis");
for (string dinosaur : dinosaurs)
console::write_line("\nbinary_search and insert \"Tyrannosaurus\":");
index = dinosaurs.binary_search("Tyrannosaurus");
if (index > dinosaurs.count()) dinosaurs.insert(~index, "Tyrannosaurus");
for (auto dinosaur : dinosaurs)
}
};
startup_(example::main);
// This code produces the following output :
//
//
// Pachycephalosaurus
// Amargasaurus
// Mamenchisaurus
// Deinonychus
//
// sort
//
// Amargasaurus
// Deinonychus
// Mamenchisaurus
// Pachycephalosaurus
//
// binary_search and insert "Coelophysis":
//
// Amargasaurus
// Coelophysis
// Deinonychus
// Mamenchisaurus
// Pachycephalosaurus
//
// binary_search and insert "Tyrannosaurus":
//
// Amargasaurus
// Coelophysis
// Deinonychus
// Mamenchisaurus
// Pachycephalosaurus
// Tyrannosaurus
typename xtd::linq::enumerable::list< type_t > list
Definition enumerable.hpp:47
static auto write_line() -> void
Writes the current line terminator to the standard output stream using the specified format informati...
#define startup_(...)
Defines the entry point to be called when the application loads. Generally this is set either to the ...
Definition startup.hpp:284
Remarks
This method uses the default comparer xtd::collections::generic::comparer::default_comparer for type type_t to determine the order of list elements. The xtd::collections::generic::comparer::default_comparer property checks whether type type_t implements the xtd::icomparable <type_t> generic interface and uses that implementation, if available. If not, xtd::collections::generic::comparer::default_comparer checks whether type T implements the xtd::icomparable interface. If type type_t does not implement either interface, xtd::collections::generic::comparer::default_comparer throws an xtd::invalid_operation_exception.
This method uses xtd::array::sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.
On average, this method is an O(n log n) operation, where n is xtd::fixed_array::count; in the worst case it is an O(n ^ 2) operation.
The following code example demonstrates the xtd::fixed_array::sort method overload and the xtd::fixed_array::binary_search method overload. A xtd::fixed_array <type_t> of strings is created and populated with four strings, in no particular order. The list is displayed, sorted, and displayed again.

◆ sort() [2/4]

template<typename type_t, xtd::usize len>
template<typename comparison_t>
auto xtd::fixed_array< type_t, len >::sort ( comparison_t && comparison) -> fixed_array &
inline

Sorts the elements in the entire xtd::fixed_array <type_t> using the specified xtd::comparison <type_t>.

Exceptions
xtd::argument_exceptionThe implementation of comparison caused an error during the sort. For example, comparison might not return 0 when comparing an item with itself.
Remarks
If comparison is provided, the elements of the xtd::fixed_array <type_t> are sorted using the method represented by the delegate.
This method uses xtd::array::sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.
On average, this method is an O(n log n) operation, where n is xtd::fixed_array::count; in the worst case it is an O(n ^ 2) operation.

◆ sort() [3/4]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::sort ( const xtd::collections::generic::icomparer< type_t > & comparer) -> fixed_array &
inline

Sorts the elements in the entire xtd::fixed_array <type_t> using the specified comparer.

Parameters
comparerThe xtd::collections::generic::icomparer <type_t> implementation to use when comparing elements, or null to use the default comparer xtd::collections::generic::comparer::default_comparer.
Exceptions
xtd::argument_exceptionThe implementation of comparison caused an error during the sort. For example, comparison might not return 0 when comparing an item with itself.
Remarks
If comparer is provided, the elements of the xtd::fixed_array <type_t> are sorted using the specified xtd::collections::generic::icomparer <type_t> implementation.
This method uses xtd::array::sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.
On average, this method is an O(n log n) operation, where n is xtd::fixed_array::count; in the worst case it is an O(n ^ 2) operation.

◆ sort() [4/4]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::sort ( xtd::usize index,
xtd::usize count,
const xtd::collections::generic::icomparer< type_t > & comparer ) -> fixed_array &
inline

Sorts the elements in a range of elements in xtd::fixed_array <type_t> using the specified comparer.

Parameters
indexThe zero-based starting index of the range to sort.
countThe length of the range to sort.
comparerThe xtd::collections::generic::icomparer <type_t> implementation to use when comparing elements, or null to use the default comparer xtd::collections::generic::comparer::default_comparer.
Exceptions
xtd::argument_exceptionThe implementation of comparison caused an error during the sort. For example, comparison might not return 0 when comparing an item with itself.
Remarks
If comparer is provided, the elements of the xtd::fixed_array <type_t> are sorted using the specified xtd::collections::generic::icomparer <type_t> implementation.
This method uses xtd::array::sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.
On average, this method is an O(n log n) operation, where n is xtd::fixed_array::count; in the worst case it is an O(n ^ 2) operation.

◆ to_array()

template<typename type_t, xtd::usize len>
virtual auto xtd::fixed_array< type_t, len >::to_array ( ) const -> xtd::array< value_type >
inlinenodiscardvirtualnoexcept

Copies the elements of the xtd::fixed_array <type_t> to a new array.

Returns
An array containing copies of the elements of the xtd::fixed_array <type_t, xtd::usize>.

◆ to_string()

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::to_string ( ) const -> xtd::string
inlinenodiscardoverridevirtualnoexcept

Returns a xtd::string that represents the current object.

Returns
A string that represents the current object.

Reimplemented from xtd::object.

◆ operator[]() [1/2]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::operator[] ( size_type index) const -> const_reference
inline

Returns a reference to the element at specified location index.

Parameters
indexThe position of the element to return.
Returns
Reference to the requested element.
Exceptions
std::out_of_rangeIf `index` is not within the range of the container.

◆ operator[]() [2/2]

template<typename type_t, xtd::usize len>
auto xtd::fixed_array< type_t, len >::operator[] ( size_type index) -> reference
inline

Returns a reference to the element at specified location index.

Parameters
indexThe position of the element to return.
Returns
Reference to the requested element.

The documentation for this class was generated from the following file: