stack

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: BSD-3-Clause Imports: 2 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[T comparable.Equality] struct {
	// contains filtered or unexported fields
}

Stack is a generic type buildt on top of a slice

func (*Stack[T]) IsEmpty

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

IsEmpty will return true if the stack is empty

func (*Stack[T]) Length

func (ns *Stack[T]) Length() int

Length returns the number of elements in the stack.

func (*Stack[T]) Peek

func (ns *Stack[T]) Peek() (*T, error)

Peek returns the top element of the stack or an error indicating that the stack is empty. Some times this is refered to a 'Top'

func (*Stack[T]) Pop

func (ns *Stack[T]) Pop() (rv *T, err error)

Pop will remove the top element from the stack. An error is returned if the stack is empty.

func (*Stack[T]) Push

func (ns *Stack[T]) Push(t *T)

Push will push new data of type [T any] onto the stack.

func (*Stack[T]) Truncate

func (ns *Stack[T]) Truncate()

Truncate removes all data from the list.

Jump to

Keyboard shortcuts

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