gods: github.com/emirpasic/gods/stacks/arraystack Index | Files

package arraystack

import "github.com/emirpasic/gods/stacks/arraystack"

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

Package Files

arraystack.go iterator.go serialization.go

type Iterator Uses

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

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

func (*Iterator) Begin Uses

func (iterator *Iterator) Begin()

Begin resets the iterator to its initial state (one-before-first) Call Next() to fetch the first element if any.

func (*Iterator) End Uses

func (iterator *Iterator) End()

End moves the iterator past the last element (one-past-the-end). Call Prev() to fetch the last element if any.

func (*Iterator) First Uses

func (iterator *Iterator) First() bool

First moves the iterator to the first element and returns true if there was a first element in the container. If First() returns true, then first element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.

func (*Iterator) Index Uses

func (iterator *Iterator) Index() int

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

func (*Iterator) Last Uses

func (iterator *Iterator) Last() bool

Last moves the iterator to the last element and returns true if there was a last element in the container. If Last() returns true, then last element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.

func (*Iterator) Next Uses

func (iterator *Iterator) Next() bool

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(). If Next() was called for the first time, then it will point the iterator to the first element if it exists. Modifies the state of the iterator.

func (*Iterator) Prev Uses

func (iterator *Iterator) Prev() bool

Prev moves the iterator to the previous element and returns true if there was a previous element in the container. If Prev() returns true, then previous element's index and value can be retrieved by Index() and Value(). Modifies the state of the iterator.

func (*Iterator) Value Uses

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

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

type Stack Uses

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

Stack holds elements in an array-list

func New Uses

func New() *Stack

New instantiates a new empty stack

func (*Stack) Clear Uses

func (stack *Stack) Clear()

Clear removes all elements from the stack.

func (*Stack) Empty Uses

func (stack *Stack) Empty() bool

Empty returns true if stack does not contain any elements.

func (*Stack) FromJSON Uses

func (stack *Stack) FromJSON(data []byte) error

FromJSON populates the stack from the input JSON representation.

func (*Stack) Iterator Uses

func (stack *Stack) Iterator() Iterator

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

func (*Stack) Peek Uses

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

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 Uses

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

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 Uses

func (stack *Stack) Push(value interface{})

Push adds a value onto the top of the stack

func (*Stack) Size Uses

func (stack *Stack) Size() int

Size returns number of elements within the stack.

func (*Stack) String Uses

func (stack *Stack) String() string

String returns a string representation of container

func (*Stack) ToJSON Uses

func (stack *Stack) ToJSON() ([]byte, error)

ToJSON outputs the JSON representation of the stack.

func (*Stack) Values Uses

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

Values returns all elements in the stack (LIFO order).

Package arraystack imports 5 packages (graph) and is imported by 11 packages. Updated 2019-08-18. Refresh now. Tools for package owners.