engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 所有成员列表
TArrayView< InElementType, InSizeType > 模板类 参考

Templated fixed-size view of another array 更多...

#include <ArrayView.h>

Public 成员函数

FORCEINLINE ElementType * begin () const
 DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.
 
FORCEINLINE void CheckInvariants () const
 Checks array invariants: if array size is greater than zero and less than maximum.
 
template<typename ComparisonType >
bool Contains (const ComparisonType &Item) const
 Checks if this array contains the element. 更多...
 
template<typename Predicate >
FORCEINLINE bool ContainsByPredicate (Predicate Pred) const
 Checks if this array contains element for which the predicate is true. 更多...
 
template<typename Predicate >
TArray< typename TRemoveConst< ElementType >::Type > FilterByPredicate (Predicate Pred) const
 Filters the elements in the array based on a predicate functor. 更多...
 
SizeType Find (const ElementType &Item) const
 Finds element within the array. 更多...
 
FORCEINLINE bool Find (const ElementType &Item, SizeType &Index) const
 Finds element within the array. 更多...
 
template<typename KeyType >
ElementType * FindByKey (const KeyType &Key) const
 Finds an item by key (assuming the ElementType overloads operator== for the comparison). 更多...
 
template<typename Predicate >
ElementType * FindByPredicate (Predicate Pred) const
 Finds an element which matches a predicate functor. 更多...
 
FORCEINLINE bool FindLast (const ElementType &Item, SizeType &Index) const
 Finds element within the array starting from the end. 更多...
 
template<typename Predicate >
FORCEINLINE SizeType FindLastByPredicate (Predicate Pred) const
 Finds element within the array starting from the end. 更多...
 
template<typename Predicate >
SizeType FindLastByPredicate (Predicate Pred, SizeType StartIndex) const
 Finds element within the array starting from StartIndex and going backwards. 更多...
 
FORCEINLINE ElementType * GetData () const
 Helper function for returning a typed pointer to the first array entry. 更多...
 
FORCEINLINE size_t GetTypeSize () const
 Helper function returning the size of the inner type. 更多...
 
template<typename KeyType >
SizeType IndexOfByKey (const KeyType &Key) const
 Finds an item by key (assuming the ElementType overloads operator== for the comparison). 更多...
 
template<typename Predicate >
SizeType IndexOfByPredicate (Predicate Pred) const
 Finds an item by predicate. 更多...
 
FORCEINLINE bool IsValidIndex (SizeType Index) const
 Tests if index is valid, i.e. 更多...
 
FORCEINLINE ElementType & Last (SizeType IndexFromTheEnd=0) const
 Returns n-th last element from the array. 更多...
 
FORCEINLINE SizeType Num () const
 Returns number of elements in array. 更多...
 
FORCEINLINE ElementType & operator[] (SizeType Index) const
 Array bracket operator. 更多...
 
FORCEINLINE void RangeCheck (SizeType Index) const
 Checks if index is in array range. 更多...
 
FORCEINLINE TArrayView Slice (SizeType Index, SizeType InNum) const
 Returns a sliced view 更多...
 
void Sort ()
 Sorts the array assuming < operator is defined for the item type.
 
template<class PREDICATE_CLASS >
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. 更多...
 
template<class PREDICATE_CLASS >
void StableSort (const PREDICATE_CLASS &Predicate)
 Stable sorts the array using user defined predicate class. 更多...
 
 TArrayView ()
 Constructor.
 
template<typename OtherElementType , typename = typename TEnableIf<TIsCompatibleElementType<OtherElementType>::Value>::Type>
FORCEINLINE TArrayView (OtherElementType *InData, SizeType InCount)
 Construct a view of an arbitrary pointer 更多...
 
template<typename OtherRangeType , typename CVUnqualifiedOtherRangeType = typename TRemoveCV<typename TRemoveReference<OtherRangeType>::Type>::Type, typename = typename TEnableIf< TAnd< TIsContiguousContainer<CVUnqualifiedOtherRangeType>, TIsCompatibleRangeType<OtherRangeType> >::Value >::Type>
FORCEINLINE TArrayView (OtherRangeType &&Other)
 Constructor from another range 更多...
 
FORCEINLINE TArrayView (std::initializer_list< ElementType > List)
 Construct a view of an initializer list. 更多...
 

详细描述

template<typename InElementType, typename InSizeType>
class TArrayView< InElementType, InSizeType >

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 lifetime 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

构造及析构函数说明

◆ TArrayView() [1/3]

template<typename InElementType , typename InSizeType >
template<typename OtherRangeType , typename CVUnqualifiedOtherRangeType = typename TRemoveCV<typename TRemoveReference<OtherRangeType>::Type>::Type, typename = typename TEnableIf< TAnd< TIsContiguousContainer<CVUnqualifiedOtherRangeType>, TIsCompatibleRangeType<OtherRangeType> >::Value >::Type>
FORCEINLINE TArrayView< InElementType, InSizeType >::TArrayView ( OtherRangeType &&  Other)
inline

Constructor from another range

参数
OtherThe source range to copy

◆ TArrayView() [2/3]

template<typename InElementType , typename InSizeType >
template<typename OtherElementType , typename = typename TEnableIf<TIsCompatibleElementType<OtherElementType>::Value>::Type>
FORCEINLINE TArrayView< InElementType, InSizeType >::TArrayView ( OtherElementType *  InData,
SizeType  InCount 
)
inline

Construct a view of an arbitrary pointer

参数
InDataThe data to view
InCountThe number of elements

◆ TArrayView() [3/3]

template<typename InElementType , typename InSizeType >
FORCEINLINE TArrayView< InElementType, InSizeType >::TArrayView ( std::initializer_list< ElementType >  List)
inline

Construct a view of an initializer list.

The caller is responsible for ensuring that the view does not outlive the initializer list.

成员函数说明

◆ Contains()

template<typename InElementType , typename InSizeType >
template<typename ComparisonType >
bool TArrayView< InElementType, InSizeType >::Contains ( const ComparisonType &  Item) const
inline

Checks if this array contains the element.

返回
True if found. False otherwise.

◆ ContainsByPredicate()

template<typename InElementType , typename InSizeType >
template<typename Predicate >
FORCEINLINE bool TArrayView< InElementType, InSizeType >::ContainsByPredicate ( Predicate  Pred) const
inline

Checks if this array contains element for which the predicate is true.

参数
Predicateto use
返回
True if found. False otherwise.

◆ FilterByPredicate()

template<typename InElementType , typename InSizeType >
template<typename Predicate >
TArray< typename TRemoveConst< ElementType >::Type > TArrayView< InElementType, InSizeType >::FilterByPredicate ( Predicate  Pred) const
inline

Filters the elements in the array based on a predicate functor.

参数
PredThe functor to apply to each element.
返回
TArray with the same type as this object which contains the subset of elements for which the functor returns true.

◆ Find() [1/2]

template<typename InElementType , typename InSizeType >
SizeType TArrayView< InElementType, InSizeType >::Find ( const ElementType &  Item) const
inline

Finds element within the array.

参数
ItemItem to look for.
返回
Index of the found element. INDEX_NONE otherwise.

◆ Find() [2/2]

template<typename InElementType , typename InSizeType >
FORCEINLINE bool TArrayView< InElementType, InSizeType >::Find ( const ElementType &  Item,
SizeType &  Index 
) const
inline

Finds element within the array.

参数
ItemItem to look for.
IndexOutput parameter. Found index.
返回
True if found. False otherwise.

◆ FindByKey()

template<typename InElementType , typename InSizeType >
template<typename KeyType >
ElementType * TArrayView< InElementType, InSizeType >::FindByKey ( const KeyType &  Key) const
inline

Finds an item by key (assuming the ElementType overloads operator== for the comparison).

参数
KeyThe key to search by.
返回
Pointer to the first matching element, or nullptr if none is found.

◆ FindByPredicate()

template<typename InElementType , typename InSizeType >
template<typename Predicate >
ElementType * TArrayView< InElementType, InSizeType >::FindByPredicate ( Predicate  Pred) const
inline

Finds an element which matches a predicate functor.

参数
PredThe functor to apply to each element.
返回
Pointer to the first element for which the predicate returns true, or nullptr if none is found.

◆ FindLast()

template<typename InElementType , typename InSizeType >
FORCEINLINE bool TArrayView< InElementType, InSizeType >::FindLast ( const ElementType &  Item,
SizeType &  Index 
) const
inline

Finds element within the array starting from the end.

参数
ItemItem to look for.
IndexOutput parameter. Found index.
返回
True if found. False otherwise.

◆ FindLastByPredicate() [1/2]

template<typename InElementType , typename InSizeType >
template<typename Predicate >
FORCEINLINE SizeType TArrayView< InElementType, InSizeType >::FindLastByPredicate ( Predicate  Pred) const
inline

Finds element within the array starting from the end.

Uses predicate to match element.

参数
PredPredicate taking array element and returns true if element matches search criteria, false otherwise.
返回
Index of the found element. INDEX_NONE otherwise.

◆ FindLastByPredicate() [2/2]

template<typename InElementType , typename InSizeType >
template<typename Predicate >
SizeType TArrayView< InElementType, InSizeType >::FindLastByPredicate ( Predicate  Pred,
SizeType  StartIndex 
) const
inline

Finds element within the array starting from StartIndex and going backwards.

Uses predicate to match element.

参数
PredPredicate taking array element and returns true if element matches search criteria, false otherwise.
StartIndexIndex of element from which to start searching.
返回
Index of the found element. INDEX_NONE otherwise.

◆ GetData()

template<typename InElementType , typename InSizeType >
FORCEINLINE ElementType * TArrayView< InElementType, InSizeType >::GetData ( ) const
inline

Helper function for returning a typed pointer to the first array entry.

返回
Pointer to first array entry or nullptr if ArrayMax == 0.

◆ GetTypeSize()

template<typename InElementType , typename InSizeType >
FORCEINLINE size_t TArrayView< InElementType, InSizeType >::GetTypeSize ( ) const
inline

Helper function returning the size of the inner type.

返回
Size in bytes of array type.

◆ IndexOfByKey()

template<typename InElementType , typename InSizeType >
template<typename KeyType >
SizeType TArrayView< InElementType, InSizeType >::IndexOfByKey ( const KeyType &  Key) const
inline

Finds an item by key (assuming the ElementType overloads operator== for the comparison).

参数
KeyThe key to search by.
返回
Index to the first matching element, or INDEX_NONE if none is found.

◆ IndexOfByPredicate()

template<typename InElementType , typename InSizeType >
template<typename Predicate >
SizeType TArrayView< InElementType, InSizeType >::IndexOfByPredicate ( Predicate  Pred) const
inline

Finds an item by predicate.

参数
PredThe predicate to match.
返回
Index to the first matching element, or INDEX_NONE if none is found.

◆ IsValidIndex()

template<typename InElementType , typename InSizeType >
FORCEINLINE bool TArrayView< InElementType, InSizeType >::IsValidIndex ( SizeType  Index) const
inline

Tests if index is valid, i.e.

than or equal to zero, and less than the number of elements in the array.

参数
IndexIndex to test.
返回
True if index is valid. False otherwise.

◆ Last()

template<typename InElementType , typename InSizeType >
FORCEINLINE ElementType & TArrayView< InElementType, InSizeType >::Last ( SizeType  IndexFromTheEnd = 0) const
inline

Returns n-th last element from the array.

参数
IndexFromTheEnd(Optional) Index from the end of array. Default is 0.
返回
Reference to n-th last element from the array.

◆ Num()

template<typename InElementType , typename InSizeType >
FORCEINLINE SizeType TArrayView< InElementType, InSizeType >::Num ( ) const
inline

Returns number of elements in array.

返回
Number of elements in array.

◆ operator[]()

template<typename InElementType , typename InSizeType >
FORCEINLINE ElementType & TArrayView< InElementType, InSizeType >::operator[] ( SizeType  Index) const
inline

Array bracket operator.

Returns reference to element at give index.

返回
Reference to indexed element.

◆ RangeCheck()

template<typename InElementType , typename InSizeType >
FORCEINLINE void TArrayView< InElementType, InSizeType >::RangeCheck ( SizeType  Index) const
inline

Checks if index is in array range.

参数
IndexIndex to check.

◆ Slice()

template<typename InElementType , typename InSizeType >
FORCEINLINE TArrayView TArrayView< InElementType, InSizeType >::Slice ( SizeType  Index,
SizeType  InNum 
) const
inline

Returns a sliced view

参数
Indexstarting index of the new view
InNumnumber of elements in the new view
返回
Sliced view

◆ Sort()

template<typename InElementType , typename InSizeType >
template<class PREDICATE_CLASS >
void TArrayView< InElementType, InSizeType >::Sort ( const PREDICATE_CLASS &  Predicate)
inline

Sorts the array using user define predicate class.

参数
PredicatePredicate class instance.

◆ StableSort() [1/2]

template<typename InElementType , typename InSizeType >
void TArrayView< InElementType, InSizeType >::StableSort ( )
inline

Stable sorts the array assuming < operator is defined for the item type.

Stable sort is slower than non-stable algorithm.

◆ StableSort() [2/2]

template<typename InElementType , typename InSizeType >
template<class PREDICATE_CLASS >
void TArrayView< InElementType, InSizeType >::StableSort ( const PREDICATE_CLASS &  Predicate)
inline

Stable sorts the array using user defined predicate class.

Stable sort is slower than non-stable algorithm.

参数
PredicatePredicate class instance

该类的文档由以下文件生成: