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

How to use
empty
method
in
smile.sort.PriorityQueue

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

origin: com.github.haifengl/smile-graph

@Override
public double[] dijkstra(int s) {
  double[] wt = new double[n];
  Arrays.fill(wt, Double.POSITIVE_INFINITY);
  PriorityQueue queue = new PriorityQueue(wt);
  for (int v = 0; v < n; v++) {
    queue.insert(v);
  }
  wt[s] = 0.0;
  queue.lower(s);
  while (!queue.empty()) {
    int v = queue.poll();
    if (!Double.isInfinite(wt[v])) {
      for (Edge edge : graph[v]) {
        int w = edge.v2;
        if (!digraph && w == v) {
          w = edge.v1;
        }
        
        double p = wt[v] + edge.weight;
        if (p < wt[w]) {
          wt[w] = p;
          queue.lower(w);
        }
      }
    }
  }
  
  return wt;
}
origin: com.github.haifengl/smile-graph

queue.lower(s);
while (!queue.empty()) {
  int v = queue.poll();
  if (!Double.isInfinite(wt[v])) {
smile.sortPriorityQueueempty

Javadoc

Returns true if the queue is empty.

Popular methods of PriorityQueue

  • <init>
    Constructor. Default use a 3-heap.
  • 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.
  • swap
    Swap i and j items of pq and qp.
  • 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 Vim 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