stack

package
v0.0.0-...-e4e1d86 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 2 Imported by: 6

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 our type that implements a stack of data items

func NewStack

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

NewStack creates a new instance of a stack with an initial capacity

func (*Stack[T]) Capacity

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

Capacity is the capacity of this stack. Stacks can grow until memory is depleted today.

func (*Stack[T]) Count

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

Count of the data inside the stack

func (*Stack[T]) Peek

func (s *Stack[T]) Peek() (bool, T)

Peek the item that would be returned from pop. Note that for LIFO situations the list consumer must mutex, otherwise the next Pop may yield a different element

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (bool, T)

Pop a value from the stack

func (*Stack[T]) Push

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

Push a value into the stack

Jump to

Keyboard shortcuts

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