Navigation
Unreal Engine C++ API Reference > Runtime > Core > Containers
Inheritance Hierarchy
- TArrayView
- FRDGUploadData
References
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Containers/ArrayView.h |
Include | #include "Containers/ArrayView.h" |
Syntax
template<typename InElementType, typename InSizeType>
class TArrayView
Remarks
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
Constructors
Type | Name | Description | |
---|---|---|---|
![]() |
TArrayView () |
Constructor. | |
![]() |
TArrayView
(
OtherRangeType&& Other |
Constructor from another range | |
![]() |
TArrayView
(
OtherRangeType&& Other |
||
![]() |
TArrayView
(
std::initializer_list< ElementType > List |
Construct a view of an initializer list. | |
![]() |
TArrayView
(
OtherElementType* InData, |
Construct a view of an arbitrary pointer |
Functions
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
ElementType * | begin () |
DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support. |
![]() ![]() |
void | Checks array invariants: if array size is greater than or equal to zero. | |
![]() ![]() |
bool | Contains
(
const ComparisonType& Item |
Checks if this array contains the element. |
![]() ![]() |
bool | ContainsByPredicate
(
Predicate Pred |
Checks if this array contains an element for which the predicate is true. |
![]() ![]() |
ElementType * | end () |
|
![]() ![]() |
TArray< std::remove_const_t< ElementType > > | FilterByPredicate
(
Predicate Pred |
Filters the elements in the array based on a predicate functor. |
![]() ![]() |
bool | Find
(
const ElementType& Item, |
Finds element within the array. |
![]() ![]() |
SizeType | Find
(
const ElementType& Item |
Finds element within the array. |
![]() ![]() |
ElementType * | FindByKey
(
const KeyType& Key |
Finds an item by key (assuming the ElementType overloads operator== for the comparison). |
![]() ![]() |
ElementType * | FindByPredicate
(
Predicate Pred |
Finds an element which matches a predicate functor. |
![]() ![]() |
bool | FindLast
(
const ElementType& Item, |
Finds element within the array starting from the end. |
![]() ![]() |
SizeType | FindLastByPredicate
(
Predicate Pred |
Finds element within the array starting from the end. Uses predicate to match element. |
![]() ![]() |
SizeType | FindLastByPredicate
(
Predicate Pred, |
Finds element within the array starting from StartIndex and going backwards. |
![]() ![]() |
ElementType * | GetData () |
Helper function for returning a typed pointer to the first array entry. |
![]() ![]() |
constexpr size_t | Helper function returning the alignment of the inner type. | |
![]() ![]() |
constexpr size_t | GetTypeSize () |
Helper function returning the size of the inner type. |
![]() ![]() |
SizeType | IndexOfByKey
(
const KeyType& Key |
Finds an item by key (assuming the ElementType overloads operator== for the comparison). |
![]() ![]() |
SizeType | IndexOfByPredicate
(
Predicate Pred |
Finds an item by predicate. |
![]() ![]() |
bool | IsEmpty () |
Returns true if the array view is empty and contains no elements. |
![]() ![]() |
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. |
![]() ![]() |
ElementType & | Returns n-th last element from the array. | |
![]() ![]() |
TArrayView | Returns the left-most part of the view by taking the given number of elements from the left. | |
![]() ![]() |
TArrayView | Returns the left-most part of the view by chopping the given number of elements from the right. | |
![]() |
void | LeftChopInline
(
SizeType CharCount |
Modifies the view by chopping the given number of elements from the right. |
![]() |
void | LeftInline
(
SizeType CharCount |
Modifies the view to be the given number of elements from the left. |
![]() ![]() |
TArrayView | Returns the middle part of the view by taking up to the given number of elements from the given position. | |
![]() |
void | Modifies the view to be the middle part by taking up to the given number of elements from the given position. | |
![]() ![]() |
SizeType | Num () |
Returns number of elements in array. |
![]() ![]() |
void | RangeCheck
(
SizeType Index |
Checks if index is in array range. |
![]() ![]() |
TReversePointerIterator< ElementType > | rbegin () |
|
![]() ![]() |
TReversePointerIterator< ElementType > | rend () |
|
![]() ![]() |
TArrayView | Returns the right-most part of the view by taking the given number of elements from the right. | |
![]() ![]() |
TArrayView | Returns the right-most part of the view by chopping the given number of elements from the left. | |
![]() |
void | RightChopInline
(
SizeType CharCount |
Modifies the view by chopping the given number of elements from the left. |
![]() |
void | RightInline
(
SizeType CharCount |
Modifies the view to be the given number of elements from the right. |
![]() ![]() |
TArrayView | 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. | |
![]() ![]() |
void | SliceRangeCheck
(
SizeType Index, |
Checks if a slice range [Index, Index+InNum) is in array range. |
![]() |
void | Sort () |
Sorts the array assuming < operator is defined for the item type. |
![]() |
void | Sort
(
const PREDICATE_CLASS& Predicate |
Sorts the array using user define predicate class. |
![]() |
void | StableSort () |
Stable sorts the array assuming < operator is defined for the item type. |
![]() |
void | StableSort
(
const PREDICATE_CLASS& Predicate |
Stable sorts the array using user defined predicate class. |
Operators
Type | Name | Description | |
---|---|---|---|
![]() ![]() |
ElementType & | operator[]
(
SizeType Index |
Array bracket operator. Returns reference to element at given index. |