Skip to content

Navigation Menu

Sign in
Sign up

Latest commit

History

19 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Go Reference Go Report Card

stack

import "github.com/bruceesmith/stack/v2"

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

Index

type Stack

Stack is a Go stack implementation using a linked list It is go-routine safe

type Stack[T any] struct {
 // contains filtered or unexported fields
}

func New

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

New creates an empty Stack

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

Generated by gomarkdoc

Versioning

This project follows Semantic Versioning.

About

Package stack defines goroutine-safe methods for manipulating a generic stack data structure

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /