Class StableLimitingSorter<T>

java.lang.Object
org.apache.druid.collections.StableLimitingSorter<T>

public class StableLimitingSorter<T> extends Object
Simultaneously sorts and limits its input. The sort is stable, meaning that equal elements (as determined by the comparator) will not be reordered. Not thread-safe. Note: this class doesn't have its own unit tests. It is tested along with TopNSequence in "TopNSequenceTest".
  • Constructor Details

    • StableLimitingSorter

      public StableLimitingSorter(Comparator<T> comparator, int limit)
  • Method Details

    • add

      public void add(T element)
      Offer an element to the sorter.
    • size

      public int size()
      Returns the number of elements currently in the sorter.
    • drain

      public Iterator<T> drain()
      Drain elements in sorted order (least first).