Tabnine Logo
PriorityQueue.swap
Code IndexAdd Tabnine to your IDE (free)

How to use
swap
method
in
smile.sort.PriorityQueue

Best Java code snippets using smile.sort.PriorityQueue.swap (Showing top 3 results out of 315)

origin: com.github.haifengl/smile-math

/**
 * fix up.
 */
private void swim(int k) {
  while (k > 1 && less(k, (k + d - 2) / d)) {
    swap(k, (k + d - 2) / d);
    k = (k + d - 2) / d;
  }
}
origin: com.github.haifengl/smile-math

/**
 * Removes and returns the index of item with minimum value (highest priority).
 */
public int poll() {
  swap(1, n);
  sink(1, n - 1);
  return pq[n--];
}
origin: com.github.haifengl/smile-math

/**
 * fix down.
 */
private void sink(int k, int N) {
  int j;
  while ((j = d * (k - 1) + 2) <= N) {
    for (int i = j + 1; i < j + d && i <= N; i++) {
      if (less(i, j)) {
        j = i;
      }
    }
    if (!(less(j, k))) {
      break;
    }
    swap(k, j);
    k = j;
  }
}
smile.sortPriorityQueueswap

Javadoc

Swap i and j items of pq and qp.

Popular methods of PriorityQueue

  • <init>
    Constructor. Default use a 3-heap.
  • empty
    Returns true if the queue is empty.
  • insert
    Insert a new item into queue.
  • less
    Priority comparison of item i and j.
  • lower
    The value of item k is lower (higher priority) now.
  • poll
    Removes and returns the index of item with minimum value (highest priority).
  • sink
    fix down.
  • swim
    fix up.

Popular in Java

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • findViewById (Activity)
  • startActivity (Activity)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • JPanel (javax.swing)
  • JTextField (javax.swing)
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top Sublime Text plugins
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