Class CustomStack<T>
- Namespace
- PAC.DataStructures
A custom implementation of a stack to allow removal of items at a specific index.
public class CustomStack<T>
Type Parameters
T
- Inheritance
-
CustomStack<T>
- Inherited Members
Properties
Count
public int Count { get; }
Property Value
Methods
Clear()
Removes all items from the stack.
public void Clear()
Peek()
Returns the item on top of the stack.
public T Peek()
Returns
- T
Pop()
Removes and returns the item on top of the stack.
public T Pop()
Returns
- T
Push(T)
Adds the item to the top of the stack.
public void Push(T item)
Parameters
item
T
Remove(T)
Removes the first occurrence (starting from the top) of the item in the stack.
public bool Remove(T item)
Parameters
item
T
Returns
- bool
true if the item is successfully removed.
RemoveAll(T)
Removes all occurrences of the item in the stack.
public void RemoveAll(T item)
Parameters
item
T
RemoveAt(int)
Removes the item at the given index and returns it.
public T RemoveAt(int index)
Parameters
index
int
Returns
- T
ToArray()
public T[] ToArray()
Returns
- T[]
ToList()
public List<T> ToList()
Returns
- List<T>