heap

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package heap is a heap container package.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

type Heap[T any] interface {
	Push(T)
	Pop() T
	Size() int
	Empty() bool
}

Heap returns a Heap interface.

Example
hp := New[int]()
hp.Push(3)
hp.Push(2)
hp.Push(5)
fmt.Println(hp.Pop())
fmt.Println("Empty:", hp.Empty())
fmt.Println("Size:", hp.Size())
Output:

2
Empty: false
Size: 2

func New

func New[T cmp.Ordered]() Heap[T]

New returns a new Heap container.

func NewWithLess

func NewWithLess[T any](less func(e1, e2 T) bool) Heap[T]

NewWithLess returns a new Heap container with custom less function.

Jump to

Keyboard shortcuts

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