Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeHeap ¶
func MakeHeap[T any](less func(i, j T) bool) (*HeapWrapper[T], *SliceInterface[T])
MakeHeap makes a heap for the type T using a less[T] function.
1st returned value is struct with basic set of heap methods. 2nd is one that implements heap.Interface[T] which is used in *HeapWrapper[T]. To add your own heap methods, embed *HeapWrapper[T] to your own struct type and manipulate SliceInterface[T].Inner slice in methods of that struct with succeeding *HeapWrapper.Init call.
func MakeMaxHeap ¶
func MakeMaxHeap[T constraints.Ordered]() (*HeapWrapper[T], *SliceInterface[T])
MakeMaxHeap makes a maxheap for the type T. This is same as MakeMinHeap but uses more[T] instead.
func MakeMinHeap ¶
func MakeMinHeap[T constraints.Ordered]() (*HeapWrapper[T], *SliceInterface[T])
MakeMinHeap makes a minheap for the type T.
MakeMinHeap does what MakeHeap does but with predeclared less function. T is constrained to predeclared primitive types which are compatible with less and greater comparison operations.
Types ¶
type HeapWrapper ¶
type HeapWrapper[T any] struct { // contains filtered or unexported fields }
func NewHeapWrapper ¶
func NewHeapWrapper[T any](inter heapparam.Interface[T]) *HeapWrapper[T]
func (*HeapWrapper[T]) Fix ¶
func (hw *HeapWrapper[T]) Fix(i int)
func (*HeapWrapper[T]) Init ¶
func (hw *HeapWrapper[T]) Init()
func (*HeapWrapper[T]) Pop ¶
func (hw *HeapWrapper[T]) Pop() T
func (*HeapWrapper[T]) Push ¶
func (hw *HeapWrapper[T]) Push(x T)
func (*HeapWrapper[T]) Remove ¶
func (hw *HeapWrapper[T]) Remove(i int) T
type SliceInterface ¶
type SliceInterface[T any] struct { Inner []T // contains filtered or unexported fields }
func NewSliceInterface ¶
func NewSliceInterface[T any](init []T, less func(i, j T) bool) *SliceInterface[T]
func (*SliceInterface[T]) Len ¶
func (sl *SliceInterface[T]) Len() int
func (*SliceInterface[T]) Less ¶
func (sl *SliceInterface[T]) Less(i, j int) bool
func (*SliceInterface[T]) Pop ¶
func (sl *SliceInterface[T]) Pop() (p T)
func (*SliceInterface[T]) Push ¶
func (sl *SliceInterface[T]) Push(x T)
func (*SliceInterface[T]) Swap ¶
func (sl *SliceInterface[T]) Swap(i, j int)
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
Code generated by github.com/ngicks/type-param-common/cmd/lenner.
|
Code generated by github.com/ngicks/type-param-common/cmd/lenner. |