Class MinHeap<T>

    • Method Detail

      • create

        public static <T extends Comparable<T>> MinHeap<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
      • 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
      • push

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

        public void popMin()
        Specified by:
        popMin in interface MinHeapI<T>
      • size

        public int size()
        Specified by:
        size in interface MinHeapI<T>
      • isEmpty

        public boolean isEmpty()
        Specified by:
        isEmpty in interface MinHeapI<T>
      • print

        public String print()
      • clear

        public void clear()
        Specified by:
        clear in interface MinHeapI<T>