stack

package
v0.0.0-...-0ad630a Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2024 License: MIT 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[V any] struct {
	// contains filtered or unexported fields
}

Stack represents a stack data structure. It is a LIFO (last in first out) data structure, which means that the last element added to the stack will be the first one to be removed.

func New

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

New returns a new stack.

func (*Stack[V]) Len

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

Len returns the number of elements in the stack.

func (*Stack[V]) Peek

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

Peek returns the last element added to the stack without removing it.

func (*Stack[V]) Pop

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

Pop removes and returns the last element added to the stack.

func (*Stack[V]) Push

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

Push adds an element to the stack.

Jump to

Keyboard shortcuts

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