hstack

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package hstack provides a simple and lean last-in/first-out stack.

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 the main type for this package. It holds the internal information about the stack.

func New

func New() *Stack

New creates a new stack.

func (*Stack) Add

func (s *Stack) Add(items ...interface{}) error

Add adds one or more new items to the top of the stack. Items are pushed in order, so the first argument is pushed first, and the second, second, and so on. This means that the last argument to Add will be the first item returned with Pop.

func (*Stack) Clear

func (s *Stack) Clear() error

Clear resets the stack to its initial state.

func (*Stack) Copy

func (s *Stack) Copy() (*Stack, error)

Copy makes an exact copy of the stack.

func (*Stack) Count

func (s *Stack) Count() int

Count gets the current number of items in the stack.

func (*Stack) Merge

func (s *Stack) Merge(ns *Stack) error

Merge adds a stack on top of the current stack. This will take ownership of and clear the provided stack.

func (*Stack) Pop

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

Pop removes the top item from the stack and returns its value.

func (*Stack) Same

func (s *Stack) Same(ns *Stack) bool

Same checks whether or not the two stacks point to the same memory.

func (*Stack) String

func (s *Stack) String() string

String displays the stack's contents, from the top to the bottom, with the top item being at the beginning of the string and the bottom item at the end.

Jump to

Keyboard shortcuts

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