heapadapter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package heapadapter provides adapters from container/heap to reaper.Heap.

The adapter does not introduce additional semantics or synchronization policies. Locking is explicit and delegated to the caller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter[T any] struct {
	// contains filtered or unexported fields
}

Adapter wraps a container/heap.Interface and exposes it as a reaper.Heap[T].

The underlying heap.Interface must store values of type T, violation of which is a programmer error and will cause a panic.

func New

func New[T any](h heap.Interface, l sync.Locker) *Adapter[T]

New constructs a new Adapter.

The provided heap.Interface is heap-initialized during construction. Locking behavior is fully controlled by the supplied sync.Locker.

func (*Adapter[T]) Empty

func (a *Adapter[T]) Empty() bool

Empty reports whether the heap contains no elements.

func (*Adapter[T]) Lock

func (a *Adapter[T]) Lock()

Lock acquires the heap lock.

func (*Adapter[T]) Pop

func (a *Adapter[T]) Pop() T

Pop removes and returns the minimum element from the heap.

If the underlying heap contains a value that is not of type T, Pop panics.

func (*Adapter[T]) Push

func (a *Adapter[T]) Push(elem T)

Push inserts an element into the heap.

func (*Adapter[T]) Unlock

func (a *Adapter[T]) Unlock()

Unlock releases the heap lock.

Jump to

Keyboard shortcuts

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