PooledStack<T> Class

Summary

A simple stack of objects. Internally it is implemented as an array, so Push can be O(n). Pop is O(1).
Namespace
Avalonia.Collections.Pooled
Interfaces
  • ICollection
  • IReadOnlyCollection<T>
  • IEnumerable<T>
  • IEnumerable
  • IDisposable
  • IDeserializationCallback
Base Types
  • object
graph BT Type-->Base0["object"] Type-.->Interface0["ICollection"] Type-.->Interface1["IReadOnlyCollection<T>"] Type-.->Interface2["IEnumerable<T>"] Type-.->Interface3["IEnumerable"] Type-.->Interface4["IDisposable"] Type-.->Interface5["IDeserializationCallback"] Type["PooledStack<T>"] class Type type-node

Syntax

[DebuggerTypeProxy(typeof(StackDebugView<>))]
[DebuggerDisplay("Count = {Count}")]
[Serializable]
public class PooledStack<T> : ICollection, IReadOnlyCollection<T>, IEnumerable<T>, IEnumerable, 
    IDisposable, IDeserializationCallback

Attributes

Type Description
DebuggerTypeProxyAttribute
DebuggerDisplayAttribute
SerializableAttribute

Type Parameters

Name Description
T

Constructors

Name Summary
PooledStack() Create a stack with the default initial capacity.
PooledStack(ArrayPool<T>) Create a stack with the default initial capacity.
PooledStack(ClearMode) Create a stack with the default initial capacity.
PooledStack(ClearMode, ArrayPool<T>) Create a stack with the default initial capacity and a custom ArrayPool.
PooledStack(IEnumerable<T>) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(IEnumerable<T>, ArrayPool<T>) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(IEnumerable<T>, ClearMode) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(IEnumerable<T>, ClearMode, ArrayPool<T>) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(int) Create a stack with a specific initial capacity. The initial capacity must be a non-negative number.
PooledStack(int, ArrayPool<T>) Create a stack with a specific initial capacity. The initial capacity must be a non-negative number.
PooledStack(int, ClearMode) Create a stack with a specific initial capacity. The initial capacity must be a non-negative number.
PooledStack(int, ClearMode, ArrayPool<T>) Create a stack with a specific initial capacity. The initial capacity must be a non-negative number.
PooledStack(ReadOnlySpan<T>) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(ReadOnlySpan<T>, ArrayPool<T>) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(ReadOnlySpan<T>, ClearMode) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(ReadOnlySpan<T>, ClearMode, ArrayPool<T>) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(T[]) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(T[], ArrayPool<T>) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(T[], ClearMode) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.
PooledStack(T[], ClearMode, ArrayPool<T>) Fills a Stack with the contents of a particular collection. The items are pushed onto the stack in the same order they are read by the enumerator.

Properties

Name Value Summary
ClearMode ClearMode
Returns the ClearMode behavior for the collection, denoting whether values are cleared from internal arrays before returning them to the pool.
Count int
The number of items in the stack.

Methods

Name Value Summary
Clear() void
Removes all Objects from the Stack.
Contains(T) bool
Compares items using the default equality comparer
CopyTo(Span<T>) void
CopyTo(T[], int) void
Dispose() void
GetEnumerator() PooledStack<T>.Enumerator
Returns an IEnumerator for this PooledStack.
Peek() T
Returns the top object on the stack without removing it. If the stack is empty, Peek throws an InvalidOperationException.
Pop() T
Pops an item from the top of the stack. If the stack is empty, Pop throws an InvalidOperationException.
Push(T) void
Pushes an item to the top of the stack.
RemoveWhere(Func<T, bool>) int
This method removes all items which match the predicate. The complexity is O(n).
ToArray() T[]
Copies the Stack to an array, in the same order Pop would return the items.
TrimExcess() void
TryPeek(T) bool
TryPop(T) bool