Package org.tinspin.index.util
Class MinHeap<T>
- java.lang.Object
-
- org.tinspin.index.util.MinHeap<T>
-
- Type Parameters:
T- Entry type
- All Implemented Interfaces:
MinHeapI<T>
public class MinHeap<T> extends Object implements MinHeapI<T>
Min-max heap implementation based on: https://en.wikipedia.org/wiki/Min-max_heap
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceMinHeap.Less<T>
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()static <T extends Comparable<T>>
MinHeap<T>create()WARNING: This is slow, seecreate(Less).static <T> MinHeap<T>create(MinHeap.Less<T> less)Providing a less() method is the preferred way to use this MinMaxHeap.booleanisEmpty()TpeekMin()voidpopMin()Stringprint()voidpush(T value)intsize()
-
-
-
Method Detail
-
create
public static <T extends Comparable<T>> MinHeap<T> create()
WARNING: This is slow, seecreate(Less). Creates a new MinMaxHeap using the compareTo method of the provided entry type.- Type Parameters:
T- The entry type. Must implementComparable<T>.- Returns:
- A new MinMaxHeap
-
create
public static <T> MinHeap<T> create(MinHeap.Less<T> less)
Providing a less() method is the preferred way to use this MinMaxHeap. Using less() is about 20% faster than using Comparator/Comparable.- Type Parameters:
T- The entry type.- Parameters:
less- A method that return `true` if the first parameter is less than the second- Returns:
- A new MinMaxHeap
-
print
public String print()
-
-