arraystack

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 24, 2016 License: BSD-2-Clause Imports: 5 Imported by: 101

Documentation

Index

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
}

func (*Iterator) Index

func (iterator *Iterator) Index() int

Returns the current element's index. Does not modify the state of the iterator.

func (*Iterator) Next

func (iterator *Iterator) Next() bool

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.

func (*Iterator) Value

func (iterator *Iterator) Value() interface{}

Returns the current element's value. Does not modify the state of the iterator.

type Stack

type Stack struct {
	// contains filtered or unexported fields
}

func New

func New() *Stack

Instantiates a new empty stack

func (*Stack) Clear

func (stack *Stack) Clear()

Removes all elements from the stack.

func (*Stack) Empty

func (stack *Stack) Empty() bool

Returns true if stack does not contain any elements.

func (*Stack) Iterator

func (stack *Stack) Iterator() Iterator

Returns a stateful iterator whose values can be fetched by an index.

func (*Stack) Peek

func (stack *Stack) Peek() (value interface{}, ok bool)

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

func (stack *Stack) Pop() (value interface{}, ok bool)

Pops (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{})

Pushes a value onto the top of the stack

func (*Stack) Size

func (stack *Stack) Size() int

Returns number of elements within the stack.

func (*Stack) String

func (stack *Stack) String() string

func (*Stack) Values

func (stack *Stack) Values() []interface{}

Returns all elements in the stack (LIFO order).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL