Documentation
¶
Index ¶
- type SafeStack
- func (s *SafeStack[T]) AssumeSafePop() T
- func (s *SafeStack[T]) Clear()
- func (s *SafeStack[T]) Len() int
- func (s *SafeStack[T]) NewMax(n int)
- func (s *SafeStack[T]) Peek() (T, error)
- func (s *SafeStack[T]) PeekAll() []T
- func (s *SafeStack[T]) PeekAtSlice() []T
- func (s *SafeStack[T]) Pop() (T, error)
- func (s *SafeStack[T]) PopAll() []T
- func (s *SafeStack[T]) PopSlice() []T
- func (s *SafeStack[T]) Push(item T)
- func (s *SafeStack[T]) PushMany(items []T)
- func (s *SafeStack[T]) RePopulate(items []T)
- func (s *SafeStack[T]) Reverse()
- func (s *SafeStack[T]) Trim(n int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SafeStack ¶
func NewSafeStack ¶
NewSafeStack - the factory function; return a *SafeStack[T]
func (*SafeStack[T]) AssumeSafePop ¶
func (s *SafeStack[T]) AssumeSafePop() T
AssumeSafePop - Pop() but brazenly assume that the stack is not empty
func (*SafeStack[T]) PeekAll ¶
func (s *SafeStack[T]) PeekAll() []T
PeekAll - return all items in the stack but leave the stack unchanged; last in first out push 1, 2, 3 -> stack [1, 2, 3] -> peek [3, 2, 1]
func (*SafeStack[T]) PeekAtSlice ¶
func (s *SafeStack[T]) PeekAtSlice() []T
PeekAtSlice - return all items in the stack but leave the stack unchanged; first in last out push 1, 2, 3 -> stack [1, 2, 3] -> peek [1, 2, 3]
func (*SafeStack[T]) PopAll ¶
func (s *SafeStack[T]) PopAll() []T
PopAll - return all items in the stack and empty the stack; last in first out push 1, 2, 3 -> stack [1, 2, 3] -> pop [3, 2, 1]
func (*SafeStack[T]) PopSlice ¶
func (s *SafeStack[T]) PopSlice() []T
PopSlice - return all items in the stack and empty the stack; first in last out push 1, 2, 3 -> stack [1, 2, 3] -> pop [1, 2, 3]
func (*SafeStack[T]) Push ¶
func (s *SafeStack[T]) Push(item T)
Push - add an item to the top of the stack; drop an item from the bottom if necessary
func (*SafeStack[T]) PushMany ¶
func (s *SafeStack[T]) PushMany(items []T)
PushMany - add multiple items to the top of the stack; first in last out push [1, 2, 3] onto [0] -> stack [0, 1, 2, 3]
func (*SafeStack[T]) RePopulate ¶
func (s *SafeStack[T]) RePopulate(items []T)
RePopulate - insert a new slice into the stack; drop down to maxsize if necessary note that here the item order is the inverse of Clear() + PushMany(): FILO vs LIFO