linked

package
v0.0.0-...-6dfbae8 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package linked contains an implementation of a stack backed by a linked list.

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.

func New

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

New returns an initialized stack.

func (*Stack[T]) Empty

func (s *Stack[T]) Empty() bool

Empty returns whether the stack is empty.

func (*Stack[T]) Len

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

Len returns the number of elements in the stack.

func (*Stack[T]) Peek

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

Peek returns the element at the top of the stack. If the stack is empty - default value for element's type is returned.

func (*Stack[T]) Pop

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

Pop removes and returns the element at the top of the stack. If the stack is empty - default value for element's type is returned.

func (*Stack[T]) Push

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

Push adds an element onto the top of the stack.

Jump to

Keyboard shortcuts

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