Add allocator tag support for Dictionary and HashSet
This commit is contained in:
@@ -163,6 +163,15 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes an empty <see cref="Dictionary"/> without reserving any space.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tag">The custom allocation tag.</param>
|
||||||
|
Dictionary(typename Base::AllocationTag tag)
|
||||||
|
: Base(tag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes <see cref="Dictionary"/> by reserving space.
|
/// Initializes <see cref="Dictionary"/> by reserving space.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -140,6 +140,15 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes an empty <see cref="HashSet"/> without reserving any space.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="tag">The custom allocation tag.</param>
|
||||||
|
HashSet(typename Base::AllocationTag tag)
|
||||||
|
: Base(tag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes <see cref="HashSet"/> by reserving space.
|
/// Initializes <see cref="HashSet"/> by reserving space.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ class HashSetBase
|
|||||||
public:
|
public:
|
||||||
// Type of allocation data used to store hash set buckets.
|
// Type of allocation data used to store hash set buckets.
|
||||||
using AllocationData = typename AllocationType::template Data<BucketType>;
|
using AllocationData = typename AllocationType::template Data<BucketType>;
|
||||||
|
using AllocationTag = typename AllocationType::Tag;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int32 _elementsCount = 0;
|
int32 _elementsCount = 0;
|
||||||
@@ -70,6 +71,11 @@ protected:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
HashSetBase(AllocationTag tag)
|
||||||
|
: _allocation(tag)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void MoveToEmpty(HashSetBase&& other)
|
void MoveToEmpty(HashSetBase&& other)
|
||||||
{
|
{
|
||||||
_elementsCount = other._elementsCount;
|
_elementsCount = other._elementsCount;
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ public:
|
|||||||
FORCE_INLINE void Swap(Data& other)
|
FORCE_INLINE void Swap(Data& other)
|
||||||
{
|
{
|
||||||
::Swap(_data, other._data);
|
::Swap(_data, other._data);
|
||||||
::Swap(_arena, other._arena);
|
_arena = other._arena; // TODO: find a better way to move allocation with AllocationUtils::MoveToEmpty to preserve/maintain allocation tag ownership
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user