stack

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package stack implements a stack. See https://en.wikipedia.org/wiki/Stack_(abstract_data_type) for more details.

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 represents a stack. Zero value of Stack is empty stack.

func New

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

New returns an initialized stack.

func (*Stack[T]) All

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

All returns all elements from the stack.

func (*Stack[T]) Peek

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

Peek returns element on top of stack.

func (*Stack[T]) Pop

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

Pop removes the most recently added element.

func (*Stack[T]) Push

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

Push adds element.

func (*Stack[T]) Size

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

Size returns size of the stack.

Jump to

Keyboard shortcuts

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