minstack

package
v0.0.0-...-d972166 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2026 License: MIT Imports: 3 Imported by: 0

README ¶

Go MinStack (Thread-Safe LIFO)

A robust, thread-safe, and flexible implementation of a MinStack (Last-In, First-Out) data structure in Go.

📦 Installation

go get [github.com/JustJ3di/Golletions/Stack](https://github.com/JustJ3di/Golletions/MinStack)

📖 Usage

package main

import (
    "fmt"

    st "[github.com/JustJ3di/Golletions/Stack](https://github.com/JustJ3di/Golletions/Stack)"
)

func main() {
	st := NewMinStack[int]()
	st.Push(12)
	st.Push(14)
	st.Push(20)
	st.Push(2)
	st.Push(100)

	fmt.Println(st.Min())
	fmt.Println(st)
	st.Pop()
	fmt.Println(st)
	a, _ := st.Pop()
	fmt.Println(st)
	fmt.Println("Popped = ", a)

	fmt.Println("New min = ", st.Min())

	fmt.Println(st)

}

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func NewMinStack ¶

func NewMinStack[T cmp.Ordered]() *minstack[T]

Types ¶

type MinStack ¶

type MinStack[T cmp.Ordered] interface {
	Push(value T)
	Pop() (T, error)
	Top() T
	Min() T
	String() string
}

Jump to

Keyboard shortcuts

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