congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
DoubleHeapSelect
Code IndexAdd Tabnine to your IDE (free)

How to use
DoubleHeapSelect
in
smile.sort

Best Java code snippets using smile.sort.DoubleHeapSelect (Showing top 5 results out of 315)

origin: com.github.haifengl/smile-math

/**
 * Returns the k-<i>th</i> smallest value seen so far.
 */
public double peek() {
  if (n < k) sort(heap, n);
  return heap[0];
}
origin: com.github.haifengl/smile-core

DoubleHeapSelect heap = new DoubleHeapSelect(k);
heap.add(Double.MAX_VALUE);
  heap.add(d);
  emptyHeap = false;
      double upperBound = emptyHeap ? Double.POSITIVE_INFINITY : heap.peek();
      if (d <= (upperBound + child.maxDist)) {
        if (c > 0 && d < upperBound) {
          if (!identicalExcluded || child.getObject() != q) {
            heap.add(d);
double upperBound = heap.peek();
for (int i = 0; i < zeroSet.size(); i++) {
  DistanceNode ds = zeroSet.get(i);
origin: com.github.haifengl/smile-math

/**
 * Sort the smallest values.
 */
public void sort() {
  if (!sorted) {
    sort(heap, Math.min(k,n));
    sorted = true;
  }
}
origin: com.github.haifengl/smile-math

/**
 * Returns the i-<i>th</i> smallest value seen so far. i = 0 returns the smallest
 * value seen, i = 1 the second largest, ..., i = k-1 the last position
 * tracked. Also, i must be less than the number of previous assimilated.
 */
public double get(int i) {
  if (i > Math.min(k, n) - 1) {
    throw new IllegalArgumentException("HeapSelect i is greater than the number of data received so far.");
  }
  if (i == k-1) {
    return heap[0];
  }
  
  if (!sorted) {
    sort(heap, Math.min(k,n));
    sorted = true;
  }
  return heap[k-1-i];
}
origin: com.github.haifengl/smile-math

/**
 * Assimilate a new value from the stream.
 */
public void add(double datum) {
  sorted = false;
  if (n < k) {
    heap[n++] = datum;
    if (n == k) {
      sort(heap, k);
    }
  } else {
    n++;
    if (datum < heap[0]) {
      heap[0] = datum;
      SortUtils.siftDown(heap, 0, k-1);
    }
  }
}
smile.sortDoubleHeapSelect

Javadoc

This class tracks the smallest values seen thus far in a stream of values. This implements a single-pass selection for large data sets. That is, we have a stream of input values, each of which we get to see only once. We want to be able to report at any time, say after n values, the i-th smallest value see so far.

Most used methods

  • <init>
    Constructor.
  • add
    Assimilate a new value from the stream.
  • peek
    Returns the k-th smallest value seen so far.
  • sort
    Sorts the specified array into descending order. It is based on Shell sort, which is very efficient

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getSystemService (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • putExtra (Intent)
  • Socket (java.net)
    Provides a client-side TCP socket.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Stack (java.util)
    Stack is a Last-In/First-Out(LIFO) data structure which represents a stack of objects. It enables u
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • Annotation (javassist.bytecode.annotation)
    The annotation structure.An instance of this class is returned bygetAnnotations() in AnnotationsAttr
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now