stack

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: Apache-2.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[E any] struct {
	// contains filtered or unexported fields
}

func FromIter

func FromIter[E any](it iter.Seq[E]) *Stack[E]

FromIter create a Stack from iter.Seq.

func FromSlice

func FromSlice[E any](elems ...E) *Stack[E]

FromSlice create a Stack from variadic elements.

func (*Stack[E]) IsEmpty

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

IsEmpty check whether Stack is empty.

func (*Stack[E]) Iter

func (s *Stack[E]) Iter() iter.Seq[E]

Iter make Stack to iter.Seq in pop order.

func (*Stack[E]) Peek

func (s *Stack[E]) Peek() (e E, ok bool)

Peek returns the top element, without pop it.

func (*Stack[E]) Pop

func (s *Stack[E]) Pop() (e E, ok bool)

Pop an element from Stack top.

Pop returns two results, the first is element and the second is a bool that indicate the value whether is valid.

func (*Stack[E]) Push

func (s *Stack[E]) Push(elem E)

Push an element to Stack top.

func (*Stack[E]) Size

func (s *Stack[E]) 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