Documentation ¶
Overview ¶
Package arraystack implements a stack backed by array list.
Structure is not thread safe.
Reference: https://en.wikipedia.org/wiki/Stack_%28abstract_data_type%29#Array
Index ¶
- type Iterator
- type Stack
- func (stack *Stack) Clear()
- func (stack *Stack) Empty() bool
- func (stack *Stack) Iterator() Iterator
- func (stack *Stack) Peek() (value interface{}, ok bool)
- func (stack *Stack) Pop() (value interface{}, ok bool)
- func (stack *Stack) Push(value interface{})
- func (stack *Stack) Size() int
- func (stack *Stack) String() string
- func (stack *Stack) Values() []interface{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Iterator ¶
type Iterator struct {
// contains filtered or unexported fields
}
Iterator returns a stateful iterator whose values can be fetched by an index.
func (*Iterator) Index ¶
Index returns the current element's index. Does not modify the state of the iterator.
func (*Iterator) Next ¶
Next moves the iterator to the next element and returns true if there was a next element in the container. If Next() returns true, then next element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.
type Stack ¶
type Stack struct {
// contains filtered or unexported fields
}
Stack holds elements in an array-list
func (*Stack) Iterator ¶
Iterator returns a stateful iterator whose values can be fetched by an index.
func (*Stack) Peek ¶
Peek returns top element on the stack without removing it, or nil if stack is empty. Second return parameter is true, unless the stack was empty and there was nothing to peek.
func (*Stack) Pop ¶
Pop removes top element on stack and returns it, or nil if stack is empty. Second return parameter is true, unless the stack was empty and there was nothing to pop.
func (*Stack) Push ¶
func (stack *Stack) Push(value interface{})
Push adds a value onto the top of the stack