A set with an optional KeyFuncs parameters for customizing how the elements are compared and searched.
更多...
|
| FORCEINLINE FSetElementId | Add (const InElementType &InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| | Adds an element to the set. 更多...
|
| |
| FORCEINLINE FSetElementId | AddByHash (uint32 KeyHash, const InElementType &InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| | Adds an element to the set. 更多...
|
| |
| template<typename OtherAllocator > |
| void | Append (const TSet< ElementType, KeyFuncs, OtherAllocator > &OtherSet) |
| | Add all items from another set to our set (union without creating a new set) 更多...
|
| |
| TArray< ElementType > | Array () const |
| |
|
FORCEINLINE TRangedForIterator | begin () |
| | DO NOT USE DIRECTLY STL-like iterators to enable range-based for loop support.
|
| |
| FORCEINLINE void | CheckAddress (const ElementType *Addr) const |
| | Checks that the specified address is not part of an element within the container. 更多...
|
| |
|
FORCEINLINE void | Compact () |
| | Compacts the allocated elements into a contiguous range.
|
| |
| FORCEINLINE void | CompactStable () |
| | Compacts the allocated elements into a contiguous range. 更多...
|
| |
| FORCEINLINE bool | Contains (KeyInitType Key) const |
| | Checks if the element contains an element with the given key. 更多...
|
| |
| template<typename ComparableKey > |
| FORCEINLINE bool | ContainsByHash (uint32 KeyHash, const ComparableKey &Key) const |
| | Checks if the element contains an element with the given key. 更多...
|
| |
|
FORCEINLINE void | CountBytes (FArchive &Ar) const |
| | Tracks the container's memory use through an archive.
|
| |
|
FORCEINLINE TConstIterator | CreateConstIterator () const |
| | Creates a const iterator for the contents of this set
|
| |
|
FORCEINLINE TIterator | CreateIterator () |
| | Creates an iterator for the contents of this set
|
| |
| TSet | Difference (const TSet &OtherSet) const |
| |
| void | Dump (FOutputDevice &Ar) |
| | Describes the set's contents through an output device. 更多...
|
| |
| template<typename ArgsType > |
| FSetElementId | Emplace (ArgsType &&Args, bool *bIsAlreadyInSetPtr=nullptr) |
| | Adds an element to the set. 更多...
|
| |
| template<typename ArgsType > |
| FSetElementId | EmplaceByHash (uint32 KeyHash, ArgsType &&Args, bool *bIsAlreadyInSetPtr=nullptr) |
| | Adds an element to the set. 更多...
|
| |
| void | Empty (int32 ExpectedNumElements=0) |
| | Removes all elements from the set, potentially leaving space allocated for an expected number of elements about to be added. 更多...
|
| |
| FORCEINLINE ElementType * | Find (KeyInitType Key) |
| | Finds an element with the given key in the set. 更多...
|
| |
| FORCEINLINE const ElementType * | Find (KeyInitType Key) const |
| | Finds an element with the given key in the set. 更多...
|
| |
| template<typename ComparableKey > |
| ElementType * | FindByHash (uint32 KeyHash, const ComparableKey &Key) |
| | Finds an element with a pre-calculated hash and a key that can be compared to KeyType. 更多...
|
| |
| FSetElementId | FindId (KeyInitType Key) const |
| | Finds an element with the given key in the set. 更多...
|
| |
| template<typename ComparableKey > |
| FSetElementId | FindIdByHash (uint32 KeyHash, const ComparableKey &Key) const |
| | Finds an element with a pre-calculated hash and a key that can be compared to KeyType 更多...
|
| |
| FORCEINLINE uint32 | GetAllocatedSize (void) const |
| | Helper function to return the amount of memory allocated by this container Only returns the size of allocations made directly by the container, not the elements themselves. 更多...
|
| |
| bool | Includes (const TSet< ElementType, KeyFuncs, Allocator > &OtherSet) const |
| | Determine whether the specified set is entirely included within this set 更多...
|
| |
| TSet | Intersect (const TSet &OtherSet) const |
| |
| FORCEINLINE bool | IsValidId (FSetElementId Id) const |
| | Checks whether an element id is valid. 更多...
|
| |
| FORCEINLINE int32 | Num () const |
| |
|
TSet & | operator= (const TSet &Copy) |
| | Assignment operator.
|
| |
|
template<typename OtherAllocator > |
| TSet & | operator= (const TSet< ElementType, KeyFuncs, OtherAllocator > &Other) |
| | Assignment operator for copying elements from a TSet with a different SetAllocator
|
| |
|
TSet & | operator= (std::initializer_list< ElementType > InitList) |
| | Initializer list assignment operator
|
| |
|
TSet & | operator= (TSet &&Other) |
| | Move assignment operator.
|
| |
|
template<typename OtherAllocator > |
| TSet & | operator= (TSet< ElementType, KeyFuncs, OtherAllocator > &&Other) |
| | Assignment operator for moving elements from a TSet with a different SetAllocator
|
| |
|
FORCEINLINE ElementType & | operator[] (FSetElementId Id) |
| | Accesses the identified element's value.
|
| |
|
FORCEINLINE const ElementType & | operator[] (FSetElementId Id) const |
| | Accesses the identified element's value.
|
| |
|
FORCEINLINE void | Relax () |
| | Relaxes the set's hash to a size strictly bounded by the number of elements in the set.
|
| |
| void | Remove (FSetElementId ElementId) |
| | Removes an element from the set. 更多...
|
| |
| int32 | Remove (KeyInitType Key) |
| | Removes all elements from the set matching the specified key. 更多...
|
| |
| template<typename ComparableKey > |
| int32 | RemoveByHash (uint32 KeyHash, const ComparableKey &Key) |
| | Removes all elements from the set matching the specified key. 更多...
|
| |
|
FORCEINLINE void | Reserve (int32 Number) |
| | Preallocates enough memory to contain Number elements
|
| |
|
void | Reset () |
| | Efficiently empties out the set but preserves all allocations and capacities
|
| |
|
FORCEINLINE void | Shrink () |
| | Shrinks the set's element storage to avoid slack.
|
| |
|
template<typename PREDICATE_CLASS > |
| void | Sort (const PREDICATE_CLASS &Predicate) |
| | Sorts the set's elements using the provided comparison class.
|
| |
|
template<typename PREDICATE_CLASS > |
| void | StableSort (const PREDICATE_CLASS &Predicate) |
| | Stable sorts the set's elements using the provided comparison class.
|
| |
|
FORCEINLINE | TSet () |
| | Initialization constructor.
|
| |
|
FORCEINLINE | TSet (const TSet &Copy) |
| | Copy constructor.
|
| |
|
template<typename OtherAllocator > |
| | TSet (const TSet< ElementType, KeyFuncs, OtherAllocator > &Other) |
| | Constructor for copying elements from a TSet with a different SetAllocator
|
| |
|
| TSet (std::initializer_list< ElementType > InitList) |
| | Initializer list constructor.
|
| |
|
| TSet (TSet &&Other) |
| | Move constructor.
|
| |
|
template<typename OtherAllocator > |
| | TSet (TSet< ElementType, KeyFuncs, OtherAllocator > &&Other) |
| | Constructor for moving elements from a TSet with a different SetAllocator
|
| |
| TSet | Union (const TSet &OtherSet) const |
| |
|
FORCEINLINE | ~TSet () |
| | Destructor.
|
| |
template<typename InElementType, typename KeyFuncs, typename Allocator>
class TSet< InElementType, KeyFuncs, Allocator >
A set with an optional KeyFuncs parameters for customizing how the elements are compared and searched.
E.g. You can specify a mapping from elements to keys if you want to find elements by specifying a subset of the element type. It uses a TSparseArray of the elements, and also links the elements into a hash with a number of buckets proportional to the number of elements. Addition, removal, and finding are O(1).
The ByHash() functions are somewhat dangerous but particularly useful in two scenarios: – Heterogeneous lookup to avoid creating expensive keys like FString when looking up by const TCHAR*. You must ensure the hash is calculated in the same way as ElementType is hashed. If possible put both ComparableKey and ElementType hash functions next to each other in the same header to avoid bugs when the ElementType hash function is changed. – Reducing contention around hash tables protected by a lock. It is often important to incur the cache misses of reading key data and doing the hashing before acquiring the lock.