stack

package
v0.0.0-...-6a6eb0f Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

type Stack []interface{}

Stack is a simple structure to hold various data

func New

func New(size int) Stack

NewStack creates a new Stack of initial size `size`.

func (*Stack) BufferSize

func (s *Stack) BufferSize() int

BufferSize returns the length of the underlying buffer

func (*Stack) Extend

func (s *Stack) Extend(extendBy int)

Extend changes the size of the underlying buffer, extending it by `extendBy`

func (*Stack) Get

func (s *Stack) Get(i int) (interface{}, error)

Get returns the element at position `i`

func (*Stack) Grow

func (s *Stack) Grow(min int)

Grow automatically grows the underlying buffer so that it can hold at least `min` elements

func (*Stack) Pop

func (s *Stack) Pop() interface{}

Pop removes and returns the item at the end of the stack

func (*Stack) Push

func (s *Stack) Push(v interface{})

Push adds an element at the end of the stack

func (*Stack) Reset

func (s *Stack) Reset()

Reset clears the contents of the stack and pushes back the cursor as if nothing is in the stack

func (*Stack) Resize

func (s *Stack) Resize(size int)

Resize changes the size of the underlying buffer

func (*Stack) Set

func (s *Stack) Set(i int, v interface{}) error

Set sets the element at position `i` to `v`. The stack size is automatically adjusted.

func (*Stack) Size

func (s *Stack) Size() int

Size returns the number of elements stored in this stack

func (*Stack) String

func (s *Stack) String() string

String returns the textual representation of the stack

func (*Stack) Top

func (s *Stack) Top() (interface{}, error)

Top returns the element at the top of the stack or an error if stack is empty

Jump to

Keyboard shortcuts

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