Class ConcurrentSlotMap<T>
- Namespace
- Misaki.HighPerformance.Collections
- Assembly
- Misaki.HighPerformance.dll
A thread-safe slot map that supports concurrent add, remove, lookup, and update operations.
public class ConcurrentSlotMap<T> : IEnumerable<T>, IEnumerable
Type Parameters
TRepresents a type that can be stored in the concurrent slot map.
- Inheritance
-
ConcurrentSlotMap<T>
- Implements
-
IEnumerable<T>
- Inherited Members
Constructors
ConcurrentSlotMap(int)
Initializes a new instance of ConcurrentSlotMap<T> with the specified initial capacity.
public ConcurrentSlotMap(int initialCapacity)
Parameters
initialCapacityintThe initial capacity of the collection.
Properties
Capacity
public int Capacity { get; }
Property Value
Count
public int Count { get; }
Property Value
Methods
Add(scoped in T, out int)
Adds an item to the collection and returns the slot index used to store it.
public int Add(scoped in T item, out int generation)
Parameters
itemTThe item to add.
generationintOutputs the generation value associated with the stored item.
Returns
- int
The slot index assigned to the item.
Clear()
public void Clear()
Contains(int, int)
public bool Contains(int slotIndex, int generation)
Parameters
Returns
GetElementAt(int, int)
public T GetElementAt(int slotIndex, int generation)
Parameters
Returns
- T
GetElementReferenceAt(int, int, out bool)
public ref T GetElementReferenceAt(int slotIndex, int generation, out bool exist)
Parameters
Returns
- T
GetEnumerator()
Gets an enumerator that iterates over the valid items in the collection.
public IEnumerator<T> GetEnumerator()
Returns
- IEnumerator<T>
An enumerator for the collection.
Remove(int, int)
public bool Remove(int slotIndex, int generation)
Parameters
Returns
Remove(int, int, out T)
Removes the item at the specified slot index and returns its value when the generation matches.
public bool Remove(int slotIndex, int generation, out T value)
Parameters
slotIndexintThe slot index to remove.
generationintThe generation to validate.
valueTWhen this method returns, contains the removed item if found.
Returns
- bool
True if the item was removed; otherwise, false.
TryGetElement(int, int, out T)
public bool TryGetElement(int slotIndex, int generation, out T value)
Parameters
Returns
UpdateElement(int, int, T)
public bool UpdateElement(int slotIndex, int generation, T newValue)