8000 GitHub - bruceesmith/stack: Package stack defines goroutine-safe methods for manipulating a generic stack data structure
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

bruceesmith/stack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Reference Go Report Card

stack

import "github.com/bruceesmith/stack"

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published
0