stack

package
v0.0.0-...-ecc870c Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: BSD-3-Clause Imports: 0 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 any] struct {
	// contains filtered or unexported fields
}

Stack is an implementation of stack container.

func New

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

New creates a new instance of Stack.

func (*Stack[T]) Get

func (s *Stack[T]) Get(index int) T

Get returns the element at index from bottom.

func (*Stack[T]) Len

func (s *Stack[T]) Len() int

Len returns the stack length.

func (*Stack[T]) Pop

func (s *Stack[T]) Pop() (top T)

Pop returns and deletes the last stack element.

func (*Stack[T]) PopPush

func (s *Stack[T]) PopPush(f T) (popped T)

PopPush executes Pop and Push operations in sequence.

func (*Stack[T]) Push

func (s *Stack[T]) Push(f T)

Push adds an element to the stack.

func (*Stack[T]) Reset

func (s *Stack[T]) Reset()

Reset resets the stack.

func (*Stack[T]) Top

func (s *Stack[T]) Top() (top T)

Top returns the last stack element.

func (*Stack[T]) TopOffsetFn

func (s *Stack[T]) TopOffsetFn(offset int, fn func(*T))

TopOffsetFn calls fn with the last stack element at offset.

Jump to

Keyboard shortcuts

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