Documentation ¶
Index ¶
- type Iterator
- type Stack
- func (s *Stack[T]) Clear()
- func (s *Stack[T]) Empty() bool
- func (s *Stack[T]) FromJSON(data []byte) error
- func (s *Stack[T]) Iterator() *Iterator[T]
- func (s *Stack[T]) Peek() (t T, _ bool)
- func (s *Stack[T]) Pop() (t T, _ bool)
- func (s *Stack[T]) Push(elem T)
- func (s *Stack[T]) Size() int
- func (s *Stack[T]) String() string
- func (s *Stack[T]) ToJSON() ([]byte, error)
- func (s *Stack[T]) Values() []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator[T comparable] struct { // contains filtered or unexported fields }
Iterator represents an iterator of array stack.
func (*Iterator[T]) Begin ¶
func (it *Iterator[T]) Begin()
Begin resets the iterator to its initial state.
func (*Iterator[T]) Index ¶
Index returns the current index of the iterator. Does not modify the state of the iterator.
type Stack ¶
type Stack[T comparable] struct { // contains filtered or unexported fields }
Stack is a last-in-first-out (LIFO) stack of elements. hold a linkedlist.
func (*Stack[T]) Peek ¶
Peek return the peek value of the stack if stack is empty return (zero-value, false)
func (*Stack[T]) Pop ¶
Pop removes the top element from the stack and returns it. It returns (zero-value, false) if the stack is empty.
func (*Stack[T]) Push ¶
func (s *Stack[T]) Push(elem T)
Push adds a new element to the top of the stack.
Click to show internal directories.
Click to hide internal directories.