binomial

package
v0.0.0-...-6223807 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 1 Imported by: 0

README

Binomial 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 Binomial

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

Binomial is a binomial queue

func New

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

New return a binomial queue with default capacity

func (*Binomial[O]) Merge

func (b *Binomial[O]) Merge(b2 *Binomial[O])

Merge bq1 to bq. ErrExceedCap returned when merge would exceed capacity

func (*Binomial[O]) Pop

func (b *Binomial[O]) Pop() O

func (*Binomial[O]) Push

func (b *Binomial[O]) Push(p O)

func (*Binomial[O]) Size

func (b *Binomial[O]) Size() int

Size get the current size of this binomial queue

Jump to

Keyboard shortcuts

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