stack

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package stack defines goroutine-safe methods for manipulating a generic stack data structure via the standard operations IsEmpty, Peek, Pop, Pushand Size.

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 Go stack implementation using a linked list It is go-routine safe

func (*Stack[T]) IsEmpty

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

IsEmpty returns true if the stack has no elements

func (*Stack[T]) Peek

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

Peek returns a copy of the top element off the stack

func (*Stack[T]) Pop

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

Pop removes the top element and returns it

func (*Stack[T]) Push

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

Push adds an element to the top of the stack

func (*Stack[T]) Size

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

Size returns the number of elements on the stack

Jump to

Keyboard shortcuts

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