loser

package
v3.3.2 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: AGPL-3.0 Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sequence

type Sequence interface {
	Next() bool // Advances and returns true if there is a value at this new position.
}

type Tree

type Tree[E any, S Sequence] struct {
	// contains filtered or unexported fields
}

A loser tree is a binary tree laid out such that nodes N and N+1 have parent N/2. We store M leaf nodes in positions M...2M-1, and M-1 internal nodes in positions 1..M-1. Node 0 is a special node, containing the winner of the contest.

func New

func New[E any, S Sequence](sequences []S, maxVal E, at func(S) E, less func(E, E) bool, close func(S)) *Tree[E, S]

func (*Tree[E, S]) Close

func (t *Tree[E, S]) Close()

Call the close function on all sequences that are still open.

func (*Tree[E, S]) Next

func (t *Tree[E, S]) Next() bool

func (*Tree[E, S]) Push

func (t *Tree[E, S]) Push(sequence S)

Add a new sequence to the merge set

func (*Tree[E, S]) Winner

func (t *Tree[E, S]) Winner() S

Jump to

Keyboard shortcuts

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