utils

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 0 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[T any] struct {
	// contains filtered or unexported fields
}

Stack is a generic stack.

func NewStack

func NewStack[T any]() *Stack[T]

NewStack creates a new, empty stack.

func (*Stack[T]) Empty

func (s *Stack[T]) Empty() bool

Empty returns whether the stack is empty.

func (*Stack[T]) Len

func (s *Stack[T]) Len() int

Len returns the size of the stack.

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() (value T)

Peek returns the top value on the stack without removing it.

func (*Stack[T]) PeekDepth

func (s *Stack[T]) PeekDepth(depth int) (value T)

PeekDepth returns the n-th value from the top. PeekDepth(0) is equivalent to the standard Peek().

func (*Stack[T]) PeekReference

func (s *Stack[T]) PeekReference() *T

PeekReference returns a reference to the top value on the stack without removing it.

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (value T)

Pop returns the top value on the stack while also removing it from the stack.

func (*Stack[T]) Push

func (s *Stack[T]) Push(value T)

Push adds the given value to the stack.

Jump to

Keyboard shortcuts

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