Struct FastStack<T>
Lightweight stack for primitive values (LIFO) to avoid List overhead.
Namespace: Evergine.Common.Collections
Assembly: Evergine.Common.dll
Syntax
public struct FastStack<T> where T : unmanaged
Type Parameters
| Name | Description |
|---|---|
| T | The type of the elements in the stack. |
Constructors
FastStack(int)
Initializes a new instance of the FastStack<T> struct with the specified initial capacity.
Declaration
public FastStack(int initialCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | initialCapacity | The initial capacity of the stack. |
Properties
Count
Gets the number of elements in the stack.
Declaration
public int Count { get; }
Property Value
| Type | Description |
|---|---|
| int |
Methods
Clear()
Clears the stack by resetting the count to zero. The internal array remains allocated, so it can be reused without additional allocations.
Declaration
public void Clear()
Peek()
Peeks at the top value of the stack without removing it. The caller must ensure that the stack is not empty before calling this method.
Declaration
public T Peek()
Returns
| Type | Description |
|---|---|
| T | The value at the top of the stack. |
Pop()
Pops a value from the stack. The caller must ensure that the stack is not empty before calling this method.
Declaration
public T Pop()
Returns
| Type | Description |
|---|---|
| T | The value popped from the stack. |
Push(T)
Pushes a value onto the stack. If the stack is full, it will resize the internal array to double its current size.
Declaration
public void Push(T value)
Parameters
| Type | Name | Description |
|---|---|---|
| T | value | The value to push onto the stack. |