Documentation ¶
Index ¶
- type Stack
- func (stack *Stack[T]) ExtractMany(amountToExtract int) (items []T, err error)
- func (stack *Stack[T]) InsertFromSlice(items []T)
- func (stack *Stack[T]) Len() int
- func (stack *Stack[T]) PeekNext() (nextItem T, err error)
- func (stack *Stack[T]) Pop() (nextItem T, err error)
- func (stack *Stack[T]) Push(item T) bool
- func (stack Stack[T]) String() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Stack ¶
type Stack[T any] struct { Items []T // contains filtered or unexported fields }
func (*Stack[T]) ExtractMany ¶
Extract many items from the stack in a new slice
args: amount of items to extract
returns: slice of the items extracted for example, if the stack is [1, 2, 3], and you request 2, the result would be [2, 3]
the method returns an error if you request to extract more items than available
func (*Stack[T]) InsertFromSlice ¶
func (stack *Stack[T]) InsertFromSlice(items []T)
Insert many items from a slice to the stack For example, if the stack is [1] and the slice is [2, 3], the stack will be [1, 2, 3]
func (*Stack[T]) PeekNext ¶
Returns the value of the next item without removing it from the stack returns an error if the stack is empty
Click to show internal directories.
Click to hide internal directories.