stacks

package
v0.12.6 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2023 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package stacks offers various utilities for handling and manipulating stack data structures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Peek

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

Peek returns the top element of the stack without removing it. If the stack is empty, it panics like accessing an index out of range.

func Pop

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

Pop removes and returns the top element of the stack. If the stack is empty, it panics like accessing an index out of range.

func Push

func Push[T any](s *Stack[T], elem T)

Push adds an element to the top of the stack.

func Size added in v0.9.0

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

Size returns the number of elements in the stack.

Types

type Stack

type Stack[T any] []T

Stack is a stack data structure.

Jump to

Keyboard shortcuts

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