Table of Contents

Class StackExtensions

Namespace
Garyon.Extensions
Assembly
Garyon.dll

Provides extensions for the Stack<T> class.

public static class StackExtensions
Inheritance
StackExtensions
Inherited Members

Methods

Insert<T>(Stack<T>, T, int)

Inserts an element in the stack at the specified index.

public static void Insert<T>(this Stack<T> stack, T item, int index)

Parameters

stack Stack<T>

The stack.

item T

The item to insert into the stack.

index int

The index at which the item will be inserted.

Type Parameters

T

The type of the values stored in the stack.

Remarks

This is an expensive operation, due to the lack of the necessary public APIs for speeding up the insertion.

PopAll<T>(Stack<T>)

Pops all elements from the stack.

public static IEnumerable<T> PopAll<T>(this Stack<T> stack)

Parameters

stack Stack<T>

The stack.

Returns

IEnumerable<T>

The popped elements in the order they were popped.

Type Parameters

T

The type of the elements contained in the stack.

PopRange<T>(Stack<T>, int)

Pops a range of elements from the stack.

public static IEnumerable<T> PopRange<T>(this Stack<T> stack, int count)

Parameters

stack Stack<T>

The stack.

count int

The number of elements to pop.

Returns

IEnumerable<T>

The popped elements in the order they were popped.

Type Parameters

T

The type of the elements contained in the stack.

PushRange<T>(Stack<T>, IEnumerable<T>)

Pushes a range of elements to the stack.

public static void PushRange<T>(this Stack<T> stack, IEnumerable<T> range)

Parameters

stack Stack<T>

The stack.

range IEnumerable<T>

The elements to push.

Type Parameters

T

The type of the elements contained in the stack.