Stck<T> Struct

Immutable stack

DECLARATION
[Serializable]
public struct Stck<T> : IEnumerable<T>,
IEnumerable,
IEquatable<Stck<T>>
NAMESPACE
LanguageExt

Constructors

Stck(IEnumerable<T>)
SUMMARY

Ctor that takes an initial state as an IEnumerable T

PARAMETERS
initial
IEnumerable<T>
DECLARATION
public ctor Stck(IEnumerable<T> initial)

Fields

Empty
DECLARATION
public static readonly Stck<T> Empty

Properties

Count
SUMMARY

Number of items in the stack

DECLARATION
[Pure]
public int Count { get; }
RETURNS
int
IsEmpty
SUMMARY

True if the stack is empty

DECLARATION
[Pure]
public bool IsEmpty { get; }
RETURNS
bool

Methods

Append(Stck<T>)
SUMMARY

Append another stack to the top of this stack The rhs will be reversed and pushed onto 'this' stack. That will maintain the order of the items in the resulting stack. So the top of 'rhs' will be the top of the newly created stack. 'this' stack will be under the 'rhs' stack.

PARAMETERS
rhs
Stck<T>
Stack to append
DECLARATION
[Pure]
public Stck<T> Append(Stck<T> rhs)
RETURNS
Stck<T>
Appended stacks
AsEnumerable()
SUMMARY

Returns the stack as an IEnumerable. The first item in the enumerable will be the item at the top of the stack.

DECLARATION
[Pure]
public IEnumerable<T> AsEnumerable()
RETURNS
IEnumerable<T>
IEnumerable of T
Clear()
SUMMARY

Clear the stack (returns Empty)

DECLARATION
[Pure]
public Stck<T> Clear()
RETURNS
Stck<T>
Stck.Empty of T
Equals(object)
PARAMETERS
obj
object
DECLARATION
[Pure]
public override bool Equals(object obj)
RETURNS
bool
Equals(Stck<T>)
PARAMETERS
other
Stck<T>
DECLARATION
[Pure]
public bool Equals(Stck<T> other)
RETURNS
bool
GetEnumerator()
SUMMARY

Get enumerator

DECLARATION
[Pure]
public IEnumerator<T> GetEnumerator()
RETURNS
IEnumerator<T>
IEnumerator of T
GetHashCode()
DECLARATION
[Pure]
public override int GetHashCode()
RETURNS
int
Peek()
SUMMARY

Return the item on the top of the stack without affecting the stack itself NOTE: Will throw an InvalidOperationException if the stack is empty

DECLARATION
[Pure]
public T Peek()
RETURNS
T
Top item value
EXCEPTIONS
InvalidOperationException
Stack is empty
Peek(Action<T>, Action)
SUMMARY

Peek and match

PARAMETERS
Some
Action<T>
Handler if there is a value on the top of the stack
None
Action
Handler if the stack is empty
DECLARATION
[Pure]
public Stck<T> Peek(Action<T> Some, Action None)
RETURNS
Stck<T>
Untouched stack (this)
Peek<R>(Func<T, R>, Func<R>)
SUMMARY

Peek and match

PARAMETERS
Some
Func<T, R>
Handler if there is a value on the top of the stack
None
Func<R>
Handler if the stack is empty
DECLARATION
[Pure]
public R Peek<R>(Func<T, R> Some, Func<R> None)
RETURNS
R
Return value from Some or None
Pop()
SUMMARY

Pop an item off the top of the stack NOTE: Will throw an InvalidOperationException if the stack is empty

DECLARATION
[Pure]
public Stck<T> Pop()
RETURNS
Stck<T>
Stack with the top item popped
EXCEPTIONS
InvalidOperationException
Stack is empty
Pop(Action<T>, Action)
SUMMARY

Pop and match

PARAMETERS
Some
Action<T>
Handler if there is a value on the top of the stack
None
Action
Handler if the stack is empty
DECLARATION
[Pure]
public Stck<T> Pop(Action<T> Some, Action None)
RETURNS
Stck<T>
Popped stack
Pop<R>(Func<Stck<T>, T, R>, Func<R>)
SUMMARY

Pop and match

PARAMETERS
Some
Func<Stck<T>, T, R>
Handler if there is a value on the top of the stack
None
Func<R>
Handler if the stack is empty
DECLARATION
[Pure]
public R Pop<R>(Func<Stck<T>, T, R> Some, Func<R> None)
RETURNS
R
Return value from Some or None
Push(T)
SUMMARY

Push an item onto the stack

PARAMETERS
value
T
Item to push
DECLARATION
[Pure]
public Stck<T> Push(T value)
RETURNS
Stck<T>
New stack with the pushed item on top
Reverse()
SUMMARY

Reverses the order of the items in the stack

DECLARATION
[Pure]
public Stck<T> Reverse()
RETURNS
Stck<T>
Subtract(Stck<T>)
SUMMARY

Append another stack to the top of this stack The rhs will be reversed and pushed onto 'this' stack. That will maintain the order of the items in the resulting stack. So the top of 'rhs' will be the top of the newly created stack. 'this' stack will be under the 'rhs' stack.

PARAMETERS
rhs
Stck<T>
Stack to append
DECLARATION
[Pure]
public Stck<T> Subtract(Stck<T> rhs)
RETURNS
Stck<T>
Appended stacks
ToSeq()
SUMMARY

Returns the stack as a Sq. The first item in the sequence will be the item at the top of the stack.

DECLARATION
[Pure]
public Seq<T> ToSeq()
RETURNS
Seq<T>
IEnumerable of T
TryPeek()
SUMMARY

Safely return the item on the top of the stack without affecting the stack itself

DECLARATION
[Pure]
public Option<T> TryPeek()
RETURNS
Option<T>
Returns the top item value, or None
TryPop()
SUMMARY

Safe pop

DECLARATION
[Pure]
public ValueTuple<Stck<T>, Option<T>> TryPop()
RETURNS
ValueTuple<Stck<T>, Option<T>>
Tuple of popped stack and optional top-of-stack value