stack

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 1 Imported by: 1

README

stack

-- import "github.com/darylnwk/stack"

Usage

type Stack
type Stack struct {
}

Stack defines a thread safe stack

func New
func New() *Stack

New initialises a new Stack

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

Peek returns the element at the top of the stack

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

Pop returns the top element and nil if the stack is empty

func (*Stack) Push
func (s *Stack) Push(elements ...interface{})

Push adds elements to the stack

func (*Stack) Size
func (s *Stack) Size() int

Size returns the total number of elements in the stack

Documentation

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 defines a thread safe stack

func New

func New() *Stack

New initialises a new Stack

func (*Stack) Peek added in v1.1.0

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

Peek returns the element at the top of the stack

func (*Stack) Pop

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

Pop returns the top element and nil if the stack is empty

func (*Stack) Push

func (s *Stack) Push(elements ...interface{})

Push adds elements to the stack

func (*Stack) Size

func (s *Stack) Size() int

Size returns the total number of elements in the stack

Jump to

Keyboard shortcuts

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