stack

package
v0.0.0-...-44b753e Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2016 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package stack provides a thread-safe stack implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

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

Stack is a thread-safe LIFO data structure.

func NewStack

func NewStack(cap int, bounded bool) *Stack

NewStack returns a new stack with its initial capacity equal to the received size and bounded set accordingly.

func (*Stack) IsEmpty

func (s *Stack) IsEmpty() bool

IsEmpty returns whether or not the stack is empty

func (*Stack) Peek

func (s *Stack) Peek() (interface{}, bool)

Peek returns the item at the top of the stack without popping it. If the stack is empty, it will return nil

func (*Stack) Pop

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

Pop pops an item off the stack {}. A nil wil be returned if the stack is empty

func (*Stack) Push

func (s *Stack) Push(item interface{}) error

Push an item on the stack. An error will occur is the stack is bounded and at capacity.

func (*Stack) Reset

func (s *Stack) Reset()

Reset restets the stack: the capacity of the stack will be reset to its initial capacity. Anything in the queue will be lost

func (*Stack) Size

func (s *Stack) Size() int

Size returns the current size of the stack (number of items)

Jump to

Keyboard shortcuts

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