stack

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: BSD-3-Clause Imports: 0 Imported by: 0

Documentation

Overview

Package stack provides implementation for Stack data structure https://simple.wikipedia.org/wiki/Stack_(data_structure)

Interface methods Push,Pop, Peek,IsEmpty,Size are the ways to interact with stack data structure. The test file stack_test.go illustrates usage of these methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Stack

type Stack[T any] interface {
	// Push element to the stack
	Push(T)

	// Pop element from the top of the stack
	// If stack is empty, panics
	Pop() T

	// Peek check the value of top element
	// If stack is empty, panics
	Peek() T

	// IsEmpty returns true if stack is empty, call before Pop and Peek
	IsEmpty() bool

	// Size returns number of elements in the stack
	Size() int
}

Interface implemented by stack, LIFO

func NewStack added in v1.1.0

func NewStack[T any]() Stack[T]

Jump to

Keyboard shortcuts

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