Struct UnsafeHashSet<T>
- Namespace
- Misaki.HighPerformance.LowLevel.Collections
- Assembly
- Misaki.HighPerformance.LowLevel.dll
A collection that provides fast, unsafe operations for managing a set of unmanaged types. It supports adding, removing, and checking for values.
public struct UnsafeHashSet<T> : IUnsafeHashCollection<T>, IDisposable where T : unmanaged, IEquatable<T>
Type Parameters
TRepresents an unmanaged type that can be compared for equality.
- Implements
- Inherited Members
Constructors
UnsafeHashSet()
Initializes a new instance of UnsafeHashSet with a default size of 1 and a persistent allocation handle.
public UnsafeHashSet()
UnsafeHashSet(int, AllocationHandle, AllocationOption)
Initializes a new instance of UnsafeHashSet with the specified initial capacity and allocation handle.
public UnsafeHashSet(int capacity, AllocationHandle handle, AllocationOption allocationOption = AllocationOption.None)
Parameters
capacityintThe initial capacity of the set.
handleAllocationHandleThe allocation handle to use for managing the set's memory.
allocationOptionAllocationOptionThe allocation options for the set.
Properties
Capacity
public readonly int Capacity { get; }
Property Value
Count
Gets the number of elements in a collection. The value is read-only.
public readonly int Count { get; }
Property Value
IsCreated
Indicates whether the object has been created. Returns true if the object is created, otherwise false.
public readonly bool IsCreated { get; }
Property Value
Methods
Add(scoped in T)
Adds a new value (unless it is already present).
public bool Add(scoped in T item)
Parameters
itemTThe value to add.
Returns
- bool
True if the value was not already present.
Clear()
Removes all elements from the collection. The collection will be empty after this operation.
public void Clear()
Contains(scoped in T)
Returns true if a particular value is present.
public bool Contains(scoped in T item)
Parameters
itemTThe value to check for.
Returns
- bool
True if the value was present.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetEnumerator()
[UnscopedRef]
public UnsafeHashSet<T>.Enumerator GetEnumerator()
Returns
GetUnsafePtr()
public readonly void* GetUnsafePtr()
Returns
- void*
Remove(scoped in T)
Removes a particular value.
public bool Remove(scoped in T item)
Parameters
itemTThe value to remove.
Returns
- bool
True if the value was present.
Resize(int, AllocationOption)
Changes the size of a collection to the specified value.
public void Resize(int newSize, AllocationOption option = AllocationOption.None)
Parameters
newSizeintSpecifies the new size to which the collection should be adjusted.
optionAllocationOptionSpecifies allocation options that may affect how memory is managed during the resize operation.
Remarks
This is to adjust the element count of the collection, not the size of the underlying buffer in memory.
ToUnsafeArray(AllocationHandle)
Returns an array with a copy of this set's values (in no particular order).
public UnsafeArray<T> ToUnsafeArray(AllocationHandle allocationHandle)
Parameters
allocationHandleAllocationHandleThe allocation handle to use to allocate the array.
Returns
- UnsafeArray<T>
An array with a copy of the set's values.
TrimExcess()
Sets the capacity to match what it would be if it had been originally initialized with all its entries.
public void TrimExcess()