Table of Contents

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

T

Represents a type that can be stored in the concurrent slot map.

Inheritance
ConcurrentSlotMap<T>
Implements
Inherited Members

Constructors

ConcurrentSlotMap(int)

Initializes a new instance of ConcurrentSlotMap<T> with the specified initial capacity.

public ConcurrentSlotMap(int initialCapacity)

Parameters

initialCapacity int

The initial capacity of the collection.

Properties

Capacity

public int Capacity { get; }

Property Value

int

Count

public int Count { get; }

Property Value

int

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

item T

The item to add.

generation int

Outputs 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

slotIndex int
generation int

Returns

bool

GetElementAt(int, int)

public T GetElementAt(int slotIndex, int generation)

Parameters

slotIndex int
generation int

Returns

T

GetElementReferenceAt(int, int, out bool)

public ref T GetElementReferenceAt(int slotIndex, int generation, out bool exist)

Parameters

slotIndex int
generation int
exist bool

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

slotIndex int
generation int

Returns

bool

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

slotIndex int

The slot index to remove.

generation int

The generation to validate.

value T

When 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

slotIndex int
generation int
value T

Returns

bool

UpdateElement(int, int, T)

public bool UpdateElement(int slotIndex, int generation, T newValue)

Parameters

slotIndex int
generation int
newValue T

Returns

bool