Class MinMaxHeap<T>

    • Method Detail

      • create

        public static <T extends Comparable<T>> MinMaxHeap<T> create()
        WARNING: This is slow, see create(Less). Creates a new MinMaxHeap using the compareTo method of the provided entry type.
        Type Parameters:
        T - The entry type. Must implement Comparable<T>.
        Returns:
        A new MinMaxHeap
      • createWithComparator

        public static <T> MinMaxHeap<T> createWithComparator​(Comparator<T> compareFn)
        WARNING: This is slow, see create(Less). Creates a new MinMaxHeap using the provided comparator for entries.
        Type Parameters:
        T - The entry type.
        Parameters:
        compareFn - Comparator for T
        Returns:
        A new MinMaxHeap
      • create

        public static <T> MinMaxHeap<T> create​(MinMaxHeap.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
      • push

        public void push​(T value)
        Specified by:
        push in interface MinMaxHeapI<T>
      • print

        public String print()