leftist

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 1 Imported by: 0

README

Leftist heap

func Example() {
	b := New[int]()
	b.Push(1)
	b.Push(9)
	b.Push(9)
	b.Push(7)
	b2 := New[int]()
	b2.Push(13)
	b2.Push(11)
	b.Merge(b2)
	for b.Size() > 0 {
		fmt.Print(b.Pop(), ",")
	}

	//Output: 1,7,9,9,11,13,
}

Documentation

Overview

Example
b := New[int]()
b.Push(1)
b.Push(9)
b.Push(9)
b.Push(7)
b2 := New[int]()
b2.Push(13)
b2.Push(11)
b.Merge(b2)
for b.Size() > 0 {
	fmt.Print(b.Pop(), ",")
}
Output:

1,7,9,9,11,13,

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Heap

type Heap[O constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func New

func New[O constraints.Ordered]() *Heap[O]

func (*Heap[O]) Merge

func (lh *Heap[O]) Merge(other *Heap[O])

func (*Heap[O]) Peek

func (lh *Heap[O]) Peek() O

func (*Heap[O]) Pop

func (lh *Heap[O]) Pop() O

func (*Heap[O]) Push

func (lh *Heap[O]) Push(o O)

func (*Heap[O]) Size

func (lh *Heap[O]) Size() int

Jump to

Keyboard shortcuts

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