stack

package
v0.0.0-...-940ab64 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: GPL-3.0 Imports: 1 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[N any] struct {
	// contains filtered or unexported fields
}

Stack a LIFO stack

func New

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

func (*Stack[N]) Empty

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

Empty returns true if there is no element in the stack, false otherwise.

func (*Stack[N]) Peek

func (s *Stack[N]) Peek() (v N, exist bool)

Peek returns the top of this stack and true, if the stack is not empty. Otherwise returns default value of N and false.

func (*Stack[N]) Pop

func (s *Stack[N]) Pop() (v N, exist bool)

Pop returns the top of this stack and true, if the stack is not empty. And remove this element from the stack. Otherwise returns default value of N and false.

func (*Stack[N]) Push

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

Push an element into stack

func (*Stack[N]) Size

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

Size returns size of stack

Jump to

Keyboard shortcuts

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