|
| UE_FORCEINLINE_HINT constexpr | UE_TCOMPACT_SET ()=default |
| |
| consteval | UE_TCOMPACT_SET (EConstEval) |
| |
| UE_FORCEINLINE_HINT | UE_TCOMPACT_SET (const UE_TCOMPACT_SET &Copy) |
| |
| UE_FORCEINLINE_HINT | UE_TCOMPACT_SET (TArrayView< const ElementType > InArrayView) |
| |
| UE_FORCEINLINE_HINT | UE_TCOMPACT_SET (TArray< ElementType > &&InArray) |
| |
| | UE_TCOMPACT_SET (std::initializer_list< ElementType > InitList) |
| |
| | UE_TCOMPACT_SET (UE_TCOMPACT_SET &&Other) |
| |
| template<typename OtherAllocator > |
| | UE_TCOMPACT_SET (UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &&Other) |
| |
| template<typename OtherAllocator > |
| | UE_TCOMPACT_SET (const UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &Other) |
| |
| UE_FORCEINLINE_HINT | ~UE_TCOMPACT_SET () |
| |
| | UE_TCOMPACT_SET (FIntrusiveUnsetOptionalState Tag) |
| |
| UE_TCOMPACT_SET & | operator= (const UE_TCOMPACT_SET &Copy) |
| |
| UE_TCOMPACT_SET & | operator= (UE_TCOMPACT_SET &&Other) |
| |
| template<typename OtherAllocator > |
| UE_TCOMPACT_SET & | operator= (UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &&Other) |
| |
| template<typename OtherAllocator > |
| UE_TCOMPACT_SET & | operator= (const UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &Other) |
| |
| UE_TCOMPACT_SET & | operator= (std::initializer_list< ElementType > InitList) |
| |
| template<typename OtherKeyFuncs , typename AliasElementType = ElementType> |
| UE_TCOMPACT_SET & | operator= (UE_TCOMPACT_SET< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, Allocator > &&Other) |
| |
| template<typename OtherKeyFuncs , typename OtherAllocator , typename AliasElementType = ElementType> |
| UE_TCOMPACT_SET & | operator= (const UE_TCOMPACT_SET< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, OtherAllocator > &Other) |
| |
| void | Empty (int32 ExpectedNumElements=0) |
| |
| void | Reset () |
| |
| void | Shrink () |
| |
| void | Reserve (int32 Number) |
| |
| void | Compact () |
| |
| void | CompactStable () |
| |
| void | SortFreeList () |
| |
| void | Relax () |
| |
| UE_FORCEINLINE_HINT SIZE_T | GetAllocatedSize () const |
| |
| void | CountBytes (FArchive &Ar) const |
| |
| UE_FORCEINLINE_HINT bool | IsValidId (FSetElementId Id) const |
| |
| UE_FORCEINLINE_HINT void | CheckInvariants () const |
| |
| void | RangeCheck (FSetElementId Id) const |
| |
| ElementType & | operator[] (FSetElementId Id) |
| |
| const ElementType & | operator[] (FSetElementId Id) const |
| |
| ElementType & | Get (FSetElementId Id) |
| |
| const ElementType & | Get (FSetElementId Id) const |
| |
| UE_FORCEINLINE_HINT FSetElementId | Add (const ElementType &InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| UE_FORCEINLINE_HINT FSetElementId | Add (ElementType &&InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| UE_FORCEINLINE_HINT FSetElementId | AddByHash (uint32 KeyHash, const ElementType &InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| UE_FORCEINLINE_HINT FSetElementId | AddByHash (uint32 KeyHash, ElementType &&InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| template<typename ArgType = ElementType> |
| UE_FORCEINLINE_HINT FSetElementId | Emplace (ArgType &&Arg, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| template<typename... ArgTypes> |
| TPair< FSetElementId, bool > | Emplace (EInPlace, ArgTypes &&... InArgs) |
| |
| template<typename ArgType = ElementType> |
| UE_FORCEINLINE_HINT FSetElementId | EmplaceByHash (uint32 KeyHash, ArgType &&Arg, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| template<typename... ArgTypes> |
| TPair< FSetElementId, bool > | EmplaceByHash (EInPlace, uint32 KeyHash, ArgTypes &&... InArgs) |
| |
| UE_FORCEINLINE_HINT ElementType & | FindOrAdd (const InElementType &InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| UE_FORCEINLINE_HINT ElementType & | FindOrAdd (InElementType &&InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| template<typename ElementReferenceType > |
| ElementType & | FindOrAddByHash (uint32 KeyHash, ElementReferenceType &&InElement, bool *bIsAlreadyInSetPtr=nullptr) |
| |
| void | Append (TArrayView< const ElementType > InElements) |
| |
| template<typename ArrayAllocator > |
| void | Append (TArray< ElementType, ArrayAllocator > &&InElements) |
| |
| template<typename OtherAllocator > |
| void | Append (const UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &OtherSet) |
| |
| template<typename OtherAllocator > |
| void | Append (UE_TCOMPACT_SET< ElementType, KeyFuncs, OtherAllocator > &&OtherSet) |
| |
| void | Append (std::initializer_list< ElementType > InitList) |
| |
| template<typename OtherKeyFuncs , typename OtherAllocator , typename AliasElementType = ElementType> |
| void | Append (const UE_TCOMPACT_SET< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, OtherAllocator > &OtherSet) |
| |
| template<typename OtherKeyFuncs , typename AliasElementType = ElementType> |
| void | Append (UE_TCOMPACT_SET< typename TContainerElementTypeCompatibility< ElementType >::CopyFromOtherType, OtherKeyFuncs, Allocator > &&OtherSet) |
| |
| ElementType * | FindArbitraryElement () |
| |
| const ElementType * | FindArbitraryElement () const |
| |
| FSetElementId | FindId (KeyInitType Key) const |
| |
| template<typename ComparableKey > |
| FSetElementId | FindIdByHash (uint32 KeyHash, const ComparableKey &Key) const |
| |
| ElementType * | Find (KeyInitType Key) |
| |
| UE_FORCEINLINE_HINT const ElementType * | Find (KeyInitType Key) const |
| |
| template<typename ComparableKey > |
| ElementType * | FindByHash (uint32 KeyHash, const ComparableKey &Key) |
| |
| template<typename ComparableKey > |
| const ElementType * | FindByHash (uint32 KeyHash, const ComparableKey &Key) const |
| |
| void | Remove (FSetElementId ElementId) |
| |
| int32 | Remove (KeyInitType Key) |
| |
| void | RemoveStable (FSetElementId ElementId) |
| |
| int32 | RemoveStable (KeyInitType Key) |
| |
| template<typename ComparableKey > |
| int32 | RemoveByHash (uint32 KeyHash, const ComparableKey &Key) |
| |
| UE_FORCEINLINE_HINT bool | Contains (KeyInitType Key) const |
| |
| template<typename ComparableKey > |
| bool | ContainsByHash (uint32 KeyHash, const ComparableKey &Key) const |
| |
| template<typename PredicateType > |
| void | Sort (const PredicateType &Predicate) |
| |
| template<typename PredicateType > |
| void | StableSort (const PredicateType &Predicate) |
| |
| void | Dump (FOutputDevice &Ar) const |
| |
| UE_TCOMPACT_SET | Intersect (const UE_TCOMPACT_SET &OtherSet) const |
| |
| UE_TCOMPACT_SET | Union (const UE_TCOMPACT_SET &OtherSet) const |
| |
| UE_TCOMPACT_SET | Difference (const UE_TCOMPACT_SET &OtherSet) const |
| |
| bool | Includes (const UE_TCOMPACT_SET< ElementType, KeyFuncs, Allocator > &OtherSet) const |
| |
| TArray< ElementType > | Array () const |
| |
| TArrayView< const ElementType > | ArrayView () const |
| |
| UE_FORCEINLINE_HINT TIterator | CreateIterator () |
| |
| UE_FORCEINLINE_HINT TConstIterator | CreateConstIterator () const |
| |
| UE_FORCEINLINE_HINT ElementType * | begin () |
| |
| UE_FORCEINLINE_HINT const ElementType * | begin () const |
| |
| UE_FORCEINLINE_HINT ElementType * | end () |
| |
| UE_FORCEINLINE_HINT const ElementType * | end () const |
| |
| void | WriteMemoryImage (FMemoryImageWriter &Writer) const |
| |
| void | CopyUnfrozen (const FMemoryUnfreezeContent &Context, void *Dst) const |
| |
| bool | operator== (FIntrusiveUnsetOptionalState Tag) const |
| |
| UE_FORCEINLINE_HINT bool | IsEmpty () const |
| |
| UE_FORCEINLINE_HINT int32 | Num () const |
| |
| UE_FORCEINLINE_HINT int32 | Max () const |
| |
| UE_FORCEINLINE_HINT int32 | GetMaxIndex () const |
| |
| UE_FORCEINLINE_HINT SIZE_T | GetAllocatedSize (const FCompactSetLayout Layout) const |
| |
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.
Here's a visual example of the data layout for the compact set
| | | | | | Data Array | Hash Size | Collision List | Hash Table | |____________|___________|________________|____________|
Data Array - Payload of the set. This is a just a regular array of items without any empty spots Hash Size - 4 byte integer to reference how big the hash table is. Storing this is significantly faster than trying to recalculate it Collision List - For each entry in the Data Array there is an entry in this list that may contain a valid index to the next item to consider for hash table collisions Hash Table - Power of 2 table to lookup the first index of a given hash value