Documentation ¶
Overview ¶
Package peap provides the implementation of a pointer-based (array-less) intrusive min-heap. Peap is a portmanteau of pointer heap.
Recommended usage: Attach a little bo.
This package is based on the paper,"Peaps: Heaps implemented without arrays": https://www.cpp.edu/~ftang/courses/CS241/notes/Building_Heaps_With_Pointers.pdf
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Element ¶
type Element[T any] interface { comparable Linker[T] Less(T) bool }
Element the item that is used at the API level.
N.B. Like Linker, this is unlikely to be an interface in most cases. If Element is not an interface, it must be a pointer.
type Entry ¶
type Entry[T Element[T]] struct { // contains filtered or unexported fields }
Entry is a default implementation of Linker. Users can embed this type in their structs to make them automatically implement most of the methods needed by Heap.
type Heap ¶
type Heap[T Element[T]] struct { // contains filtered or unexported fields }
Heap implement a pointer-based min-heap.
type Linker ¶
type Linker[T any] interface { Left() T Right() T SetLeft(T) SetRight(T) }
Linker is the interface that objects must implement if they want to be added to and/or removed from Heap objects.
N.B. When substituted in a template instantiation, Linker doesn't need to be an interface, and in most cases won't be.