Navigation
API > API/Runtime > API/Runtime/Core
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
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
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
| Name | TArrayView |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Containers/ArrayView.h |
| Include Path | #include "Containers/ArrayView.h" |
Syntax
template<typename InElementType, typename InSizeType>
class TArrayView
Derived Classes
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
constexpr TArrayView () |
Constructor. | Containers/ArrayView.h | |
constexpr TArrayView
(
const TArrayView& |
Defaulted object behavior - we want compiler-generated functions rather than going through the generic range constructor. | Containers/ArrayView.h | |
constexpr TArrayView
(
OtherRangeType&& Other |
Constructor from another range | Containers/ArrayView.h | |
constexpr TArrayView
(
OtherRangeType&& Other |
Containers/ArrayView.h | ||
constexpr TArrayView
(
std::initializer_list< ElementType > List |
Construct a view of an initializer list. | Containers/ArrayView.h | |
constexpr TArrayView
(
FIntrusiveUnsetOptionalState |
Containers/ArrayView.h | ||
constexpr TArrayView
(
OtherElementType* InData, |
Construct a view of an arbitrary pointer | Containers/ArrayView.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TArrayView() |
Containers/ArrayView.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ElementType | InElementType | Containers/ArrayView.h | |
| IntrusiveUnsetOptionalStateType | TArrayView | Containers/ArrayView.h | |
| SizeType | InSizeType | Containers/ArrayView.h | |
| TIsCompatibleRangeType | UE::Core::ArrayView::Private::TIsCompatibleRangeType< T, ElementType > | Containers/ArrayView.h | |
| TIsReinterpretableRangeType | UE::Core::ArrayView::Private::TIsReinterpretableRangeType< T, ElementType > | Containers/ArrayView.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| bHasIntrusiveUnsetOptionalState | bool | Start - intrusive TOptional |
Containers/ArrayView.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ArrayNum | SizeType | Containers/ArrayView.h | ||
| DataPtr | ElementType * | Containers/ArrayView.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ElementType * begin() |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. | Containers/ArrayView.h | |
void CheckInvariants() |
Checks array invariants: if array size is greater than or equal to zero. | Containers/ArrayView.h | |
bool Contains
(
const ComparisonType& Item |
Checks if this array contains the element. | Containers/ArrayView.h | |
bool ContainsByPredicate
(
Predicate Pred |
Checks if this array contains an element for which the predicate is true. | Containers/ArrayView.h | |
ElementType * end() |
Containers/ArrayView.h | ||
TArray< std::remove_const_t< ElementType > > FilterByPredicate
(
Predicate Pred |
Filters the elements in the array based on a predicate functor. | Containers/ArrayView.h | |
bool Find
(
const ElementType& Item, |
Finds element within the array. | Containers/ArrayView.h | |
SizeType Find
(
const ElementType& Item |
Finds element within the array. | Containers/ArrayView.h | |
ElementType * FindByKey
(
const KeyType& Key |
Finds an item by key (assuming the ElementType overloads operator== for the comparison). | Containers/ArrayView.h | |
ElementType * FindByPredicate
(
Predicate Pred |
Finds an element which matches a predicate functor. | Containers/ArrayView.h | |
SizeType FindLast
(
const ElementType& Item |
Finds element within the array starting from the end. | Containers/ArrayView.h | |
bool FindLast
(
const ElementType& Item, |
Finds element within the array starting from the end. | Containers/ArrayView.h | |
SizeType FindLastByPredicate
(
Predicate Pred |
Finds element within the array starting from the end. Uses predicate to match element. | Containers/ArrayView.h | |
SizeType FindLastByPredicate
(
Predicate Pred, |
Finds element within the array starting from StartIndex and going backwards. | Containers/ArrayView.h | |
ElementType * GetData () |
End - intrusive TOptional |
Containers/ArrayView.h | |
SizeType IndexOfByKey
(
const KeyType& Key |
Finds an item by key (assuming the ElementType overloads operator== for the comparison). | Containers/ArrayView.h | |
SizeType IndexOfByPredicate
(
Predicate Pred |
Finds an item by predicate. | Containers/ArrayView.h | |
bool IsEmpty () |
Returns true if the array view is empty and contains no elements. | Containers/ArrayView.h | |
bool IsValidIndex
(
SizeType Index |
Tests if index is valid, i.e. greater than or equal to zero, and less than the number of elements in the array. | Containers/ArrayView.h | |
ElementType & Last
(
SizeType IndexFromTheEnd |
Returns n-th last element from the array. | Containers/ArrayView.h | |
TArrayView Left
(
SizeType Count |
Returns the left-most part of the view by taking the given number of elements from the left. | Containers/ArrayView.h | |
TArrayView LeftChop
(
SizeType Count |
Returns the left-most part of the view by chopping the given number of elements from the right. | Containers/ArrayView.h | |
void LeftChopInline
(
SizeType CharCount |
Modifies the view by chopping the given number of elements from the right. | Containers/ArrayView.h | |
void LeftInline
(
SizeType CharCount |
Modifies the view to be the given number of elements from the left. | Containers/ArrayView.h | |
TArrayView Mid
(
SizeType Index, |
Returns the middle part of the view by taking up to the given number of elements from the given position. | Containers/ArrayView.h | |
void MidInline
(
SizeType Position, |
Modifies the view to be the middle part by taking up to the given number of elements from the given position. | Containers/ArrayView.h | |
SizeType Num() |
Returns number of elements in array. | Containers/ArrayView.h | |
SIZE_T NumBytes() |
Containers/ArrayView.h | ||
void RangeCheck
(
SizeType Index |
Checks if index is in array range. | Containers/ArrayView.h | |
TReversePointerIterator< ElementType > rbegin() |
Containers/ArrayView.h | ||
TReversePointerIterator< ElementType > rend() |
Containers/ArrayView.h | ||
TArrayView Right
(
SizeType Count |
Returns the right-most part of the view by taking the given number of elements from the right. | Containers/ArrayView.h | |
TArrayView RightChop
(
SizeType Count |
Returns the right-most part of the view by chopping the given number of elements from the left. | Containers/ArrayView.h | |
void RightChopInline
(
SizeType CharCount |
Modifies the view by chopping the given number of elements from the left. | Containers/ArrayView.h | |
void RightInline
(
SizeType CharCount |
Modifies the view to be the given number of elements from the right. | Containers/ArrayView.h | |
TArrayView Slice
(
SizeType Index, |
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. | Containers/ArrayView.h | |
void SliceRangeCheck
(
SizeType Index, |
Checks if a slice range [Index, Index+InNum) is in array range. | Containers/ArrayView.h | |
void Sort () |
Sorts the array assuming < operator is defined for the item type. | Containers/ArrayView.h | |
void Sort
(
const PREDICATE_CLASS& Predicate |
Sorts the array using user define predicate class. | Containers/ArrayView.h | |
void StableSort
(
const PREDICATE_CLASS& Predicate |
Stable sorts the array using user defined predicate class. | Containers/ArrayView.h | |
void StableSort () |
Stable sorts the array assuming < operator is defined for the item type. | Containers/ArrayView.h | |
bool UEOpEquals
(
FIntrusiveUnsetOptionalState |
Containers/ArrayView.h | ||
bool UEOpEquals
(
TArrayView< OtherElementType, OtherSizeType > |
Comparison of array views to each other is not implemented because it is not obvious whether the caller wants an exact match of the data pointer and size, or to compare the objects being pointed to. | Containers/ArrayView.h | |
bool UEOpEquals
(
RangeType&& Rhs |
Equality operator. | Containers/ArrayView.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static size_t GetTypeAlignment() |
Helper function returning the alignment of the inner type. | Containers/ArrayView.h | |
static size_t GetTypeSize() |
Helper function returning the size of the inner type. | Containers/ArrayView.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
ElementType & operator[]
(
SizeType Index |
Array bracket operator. Returns reference to element at given index. | Containers/ArrayView.h | |
TArrayView & operator=
(
const TArrayView& |
Containers/ArrayView.h |