stack

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(option *Options)

Option is a function type used to set Options

func WithContainer

func WithContainer(c container.Container) Option

WithContainer is used to set a stack's underlying container

func WithGoroutineSafe

func WithGoroutineSafe() Option

WithGoroutineSafe is used to set a stack goroutine-safe

func WithListContainer

func WithListContainer() Option

WithListContainer is used to set List for a stack's underlying container

type Options

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

Options holds the Stack's options

type Stack

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

Stack is a last-in-first-out data structure

func New

func New(opts ...Option) *Stack

New creates a new stack

func (*Stack) Clear

func (s *Stack) Clear()

Clear clears all elements in the stack

func (*Stack) Empty

func (s *Stack) Empty() bool

Empty returns true if the stack is empty, otherwise returns false

func (*Stack) Pop

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

Pop removes the the top value in the stack and returns it

func (*Stack) Push

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

Push pushes a value to the stack

func (*Stack) Size

func (s *Stack) Size() int

Size returns the amount of elements in the stack

func (*Stack) String

func (s *Stack) String() string

String returns a string representation of the stack

func (*Stack) Top

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

Top returns the top value in the stack

Jump to

Keyboard shortcuts

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