Ark Server API (ASA) - Wiki
|
#include <ArrayView.h>
Public Types | |
using | ElementType = InElementType |
using | SizeType = InSizeType |
Static Public Member Functions | |
static FORCEINLINE constexpr size_t | GetTypeSize () |
static FORCEINLINE constexpr size_t | GetTypeAlignment () |
Private Types | |
template<typename T > | |
using | TIsCompatibleElementType = ArrayViewPrivate::TIsCompatibleElementType<T, ElementType> |
template<typename T > | |
using | TIsCompatibleRangeType = ArrayViewPrivate::TIsCompatibleRangeType<T, ElementType> |
template<typename T > | |
using | TIsReinterpretableRangeType = ArrayViewPrivate::TIsReinterpretableRangeType<T, ElementType> |
Private Attributes | |
ElementType * | DataPtr |
SizeType | ArrayNum |
Templated fixed-size view of another array
A statically sized view of an array of typed elements. Designed to allow functions to take either a fixed C array or a TArray with an arbitrary allocator as an argument when the function neither adds nor removes elements
e.g.: int32 SumAll(TArrayView<const int32> array) { return Algo::Accumulate(array); }
could be called as: SumAll(MyTArray);\ SumAll(MyCArray); SumAll(MakeArrayView(Ptr, Num));
auto Values = { 1, 2, 3 }; SumAll(Values);
Note: View classes are not const-propagating! If you want a view where the elements are const, you need "TArrayView<const T>" not "const TArrayView<T>"!
Caution: Treat a view like a reference to the elements in the array. DO NOT free or reallocate the array while the view exists! For this reason, be mindful of lifetimes when constructing TArrayViews from rvalue initializer lists:
TArrayView<int> View = { 1, 2, 3 }; // construction of array view from rvalue initializer list int n = View[0]; // undefined behavior, as the initializer list was destroyed at the end of the previous line
Definition at line 129 of file ArrayView.h.
using TArrayView< InElementType, InSizeType >::ElementType = InElementType |
Definition at line 132 of file ArrayView.h.
using TArrayView< InElementType, InSizeType >::SizeType = InSizeType |
Definition at line 133 of file ArrayView.h.
|
private |
Definition at line 148 of file ArrayView.h.
|
private |
Definition at line 151 of file ArrayView.h.
|
private |
Definition at line 154 of file ArrayView.h.
|
inline |
Constructor.
Definition at line 140 of file ArrayView.h.
|
inline |
Constructor from another range
Other | The source range to copy |
Definition at line 176 of file ArrayView.h.
|
inline |
Definition at line 201 of file ArrayView.h.
|
inline |
Construct a view of an arbitrary pointer
InData | The data to view |
InCount | The number of elements |
Definition at line 221 of file ArrayView.h.
|
inline |
Construct a view of an initializer list.
The caller is responsible for ensuring that the view does not outlive the initializer list.
Definition at line 233 of file ArrayView.h.
|
inline |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.
Definition at line 686 of file ArrayView.h.
|
inline |
Checks array invariants: if array size is greater than or equal to zero.
Definition at line 273 of file ArrayView.h.
|
inline |
Checks if this array contains the element.
Definition at line 656 of file ArrayView.h.
|
inline |
Checks if this array contains an element for which the predicate is true.
Predicate | to use |
Definition at line 676 of file ArrayView.h.
|
inline |
Definition at line 687 of file ArrayView.h.
|
inline |
Filters the elements in the array based on a predicate functor.
Pred | The functor to apply to each element. |
Definition at line 637 of file ArrayView.h.
|
inline |
Finds element within the array.
Item | Item to look for. |
Definition at line 476 of file ArrayView.h.
|
inline |
Finds element within the array.
Item | Item to look for. |
Index | Output parameter. Found index. |
Definition at line 463 of file ArrayView.h.
|
inline |
Finds an item by key (assuming the ElementType overloads operator== for the comparison).
Key | The key to search by. |
Definition at line 593 of file ArrayView.h.
|
inline |
Finds an element which matches a predicate functor.
Pred | The functor to apply to each element. |
Definition at line 615 of file ArrayView.h.
|
inline |
Finds element within the array starting from the end.
Item | Item to look for. |
Index | Output parameter. Found index. |
Definition at line 497 of file ArrayView.h.
|
inline |
Finds element within the array starting from the end. Uses predicate to match element.
Pred | Predicate taking array element and returns true if element matches search criteria, false otherwise. |
Definition at line 534 of file ArrayView.h.
|
inline |
Finds element within the array starting from StartIndex and going backwards. Uses predicate to match element.
Pred | Predicate taking array element and returns true if element matches search criteria, false otherwise. |
StartIndex | Index of element from which to start searching. |
Definition at line 512 of file ArrayView.h.
|
inline |
Helper function for returning a typed pointer to the first array entry.
Definition at line 247 of file ArrayView.h.
|
inlinestaticconstexpr |
Helper function returning the alignment of the inner type.
Definition at line 265 of file ArrayView.h.
|
inlinestaticconstexpr |
Helper function returning the size of the inner type.
Definition at line 257 of file ArrayView.h.
|
inline |
Finds an item by key (assuming the ElementType overloads operator== for the comparison).
Key | The key to search by. |
Definition at line 549 of file ArrayView.h.
|
inline |
Finds an item by predicate.
Pred | The predicate to match. |
Definition at line 571 of file ArrayView.h.
|
inline |
Returns true if the array view is empty and contains no elements.
Definition at line 322 of file ArrayView.h.
|
inline |
Tests if index is valid, i.e. greater than or equal to zero, and less than the number of elements in the array.
Index | Index to test. |
Definition at line 311 of file ArrayView.h.
|
inline |
Returns n-th last element from the array.
IndexFromTheEnd | (Optional) Index from the end of array. Default is 0. |
Definition at line 356 of file ArrayView.h.
|
inline |
Returns the left-most part of the view by taking the given number of elements from the left.
Definition at line 379 of file ArrayView.h.
|
inline |
Returns the left-most part of the view by chopping the given number of elements from the right.
Definition at line 385 of file ArrayView.h.
|
inline |
Modifies the view by chopping the given number of elements from the right.
Definition at line 432 of file ArrayView.h.
|
inline |
Modifies the view to be the given number of elements from the left.
Definition at line 426 of file ArrayView.h.
|
inline |
Returns the middle part of the view by taking up to the given number of elements from the given position.
Definition at line 405 of file ArrayView.h.
|
inline |
Modifies the view to be the middle part by taking up to the given number of elements from the given position.
Definition at line 450 of file ArrayView.h.
|
inline |
Returns number of elements in array.
Definition at line 332 of file ArrayView.h.
|
inline |
Array bracket operator. Returns reference to element at given index.
Definition at line 342 of file ArrayView.h.
|
inline |
Checks if index is in array range.
Index | Index to check. |
Definition at line 283 of file ArrayView.h.
|
inline |
Returns the right-most part of the view by taking the given number of elements from the right.
Definition at line 391 of file ArrayView.h.
|
inline |
Returns the right-most part of the view by chopping the given number of elements from the left.
Definition at line 398 of file ArrayView.h.
|
inline |
Modifies the view by chopping the given number of elements from the left.
Definition at line 444 of file ArrayView.h.
|
inline |
Modifies the view to be the given number of elements from the right.
Definition at line 438 of file ArrayView.h.
|
inline |
Returns a sliced view This is similar to Mid(), but with a narrow contract, i.e. slicing outside of the range of the view is illegal.
Index | starting index of the new view |
InNum | number of elements in the new view |
Definition at line 372 of file ArrayView.h.
|
inline |
Checks if a slice range [Index, Index+InNum) is in array range. Length is 0 is allowed on empty arrays; Index must be 0 in that case.
Index | Starting index of the slice. |
InNum | Length of the slice. |
Definition at line 297 of file ArrayView.h.
|
inline |
Sorts the array assuming < operator is defined for the item type.
Definition at line 693 of file ArrayView.h.
|
inline |
Sorts the array using user define predicate class.
Predicate | Predicate class instance. |
Definition at line 704 of file ArrayView.h.
|
inline |
Stable sorts the array assuming < operator is defined for the item type.
Stable sort is slower than non-stable algorithm.
Definition at line 714 of file ArrayView.h.
|
inline |
Stable sorts the array using user defined predicate class.
Stable sort is slower than non-stable algorithm.
Predicate | Predicate class instance |
Definition at line 727 of file ArrayView.h.
|
private |
Definition at line 734 of file ArrayView.h.
|
private |
Definition at line 733 of file ArrayView.h.