Examples of PriorityQueue


Examples of com.vividsolutions.jts.util.PriorityQueue

  {
    double distanceLowerBound = maxDistance;
    BoundablePair minPair = null;
   
    // initialize internal structures
    PriorityQueue priQ = new PriorityQueue();

    // initialize queue
    priQ.add(initBndPair);

    while (! priQ.isEmpty() && distanceLowerBound > 0.0) {
      // pop head of queue and expand one side of pair
      BoundablePair bndPair = (BoundablePair) priQ.poll();
      double currentDistance = bndPair.getDistance();
     
      /**
       * If the distance for the first node in the queue
       * is >= the current minimum distance, all other nodes
View Full Code Here

Examples of dovetaildb.util.PriorityQueue

 
 
  public static SegmentPush balanceSegmentPush(SegmentPush segment, int threshold) {
    long ct = segment.count;
    if (ct <= threshold) return segment;
    PriorityQueue queue = new PriorityQueue(500) {
      @Override
      public int compare(Object a, Object b) {
        AdjacencyRec r1 = (AdjacencyRec)a;
        AdjacencyRec r2 = (AdjacencyRec)b;
        return (int)((r1.ct1+r2.ct2) - (r2.ct1+r2.ct2));
      }
    };
    Iterator<PostingNode> itr = segment.iterator();
    PostingNode firstNode = itr.next();
    PostingNode secondNode = itr.next();
    AdjacencyRec firstAdj = new AdjacencyRec(firstNode, secondNode);
    queue.insertAndGrow(firstAdj);
    AdjacencyRec prevAdj = firstAdj;
    while(itr.hasNext()) {
      PostingNode curNode = itr.next();
      AdjacencyRec adj = new AdjacencyRec(curNode, prevAdj);
      queue.insertAndGrow(adj);
      prevAdj = adj;
    }
    while(queue.size >= threshold) {
      AdjacencyRec rec = (AdjacencyRec)queue.pop();
      if (rec.dirty) {
        rec.dirty = false;
        queue.insert(rec);
      } else {
        rec.node1.addAll(rec.node2);
        if (rec.left != null) {
          rec.left.right = rec.right;
          rec.left.ct2 += rec.ct2;
View Full Code Here

Examples of edu.emory.mathcs.backport.java.util.PriorityQueue

    protected AbstractBoundedEventHeap(int capacity, EventQueueOverflowStrategy overflowStrategy, Object lock, Comparator comparator)
    {
        super(capacity, overflowStrategy, lock);

        heap_ = new PriorityQueue(capacity, comparator);
    }
View Full Code Here

Examples of general.datastructures.PriorityQueue

 
 
  @Test(expected = EmptyListException.class)
  public void testPriorityQueueEmpty() throws EmptyListException
  {
    PriorityQueue pq;
    pq = new PriorityQueue();
   
    assertNotNull(pq);
    assertTrue(pq.isEmpty());
   
    pq.getFirst();
   
  }
View Full Code Here

Examples of java.util.PriorityQueue

    Class nextClass = type;
    while (nextClass != null && nextClass != Object.class) {
      Collections.addAll(allMethods, nextClass.getDeclaredMethods());
      nextClass = nextClass.getSuperclass();
    }
    PriorityQueue<Method> methods = new PriorityQueue(Math.max(1, allMethods.size()), new Comparator<Method>() {
      public int compare (Method o1, Method o2) {
        // Methods are sorted so they can be represented as an index.
        int diff = o1.getName().compareTo(o2.getName());
        if (diff != 0) return diff;
        Class[] argTypes1 = o1.getParameterTypes();
        Class[] argTypes2 = o2.getParameterTypes();
        if (argTypes1.length > argTypes2.length) return 1;
        if (argTypes1.length < argTypes2.length) return -1;
        for (int i = 0; i < argTypes1.length; i++) {
          diff = argTypes1[i].getName().compareTo(argTypes2[i].getName());
          if (diff != 0) return diff;
        }
        throw new RuntimeException("Two methods with same signature!"); // Impossible.
      }
    });
    for (int i = 0, n = allMethods.size(); i < n; i++) {
      Method method = allMethods.get(i);
      int modifiers = method.getModifiers();
      if (Modifier.isStatic(modifiers)) continue;
      if (Modifier.isPrivate(modifiers)) continue;
      if (method.isSynthetic()) continue;
      methods.add(method);
    }

    int n = methods.size();
    cachedMethods = new CachedMethod[n];
    for (int i = 0; i < n; i++) {
      CachedMethod cachedMethod = new CachedMethod();
      cachedMethod.method = methods.poll();

      // Store the serializer for each final parameter.
      Class[] parameterTypes = cachedMethod.method.getParameterTypes();
      cachedMethod.serializers = new Serializer[parameterTypes.length];
      for (int ii = 0, nn = parameterTypes.length; ii < nn; ii++)
View Full Code Here

Examples of java.util.PriorityQueue

        if ( capacity == 0 ) {
            return;
        }

        this.queue = new PriorityQueue( capacity,
                                        new Comparator<SimulationStep>() {
                                            public int compare(SimulationStep s1,
                                                               SimulationStep s2) {
                                                return (int) (s1.getDistanceMillis() - s2.getDistanceMillis());
                                            }
View Full Code Here

Examples of java.util.PriorityQueue

        if ( capacity == 0 ) {
            return;
        }

        this.queue = new PriorityQueue( capacity,
                                        new Comparator<Step>() {
                                            public int compare(Step s1,
                                                               Step s2) {
                                                return (int) (s1.getTemporalDistance() - s2.getTemporalDistance());
                                            }
View Full Code Here

Examples of java.util.PriorityQueue

        if ( capacity == 0 ) {
            return;
        }

        this.queue = new PriorityQueue( capacity,
                                        new Comparator<Step>() {
                                            public int compare(Step s1,
                                                               Step s2) {
                                                return (int) (s1.getTemporalDistance() - s2.getTemporalDistance());
                                            }
View Full Code Here

Examples of java.util.PriorityQueue

  public void checkProperties() {
    ArrayList algoList = (ArrayList) msgProp.getProperties(AlgorithmSuitePropertyFactory.K_AlgoList);
    Iterator algoSuites = algoList.iterator();
    ArrayList tempAlgo;
    PriorityQueue q = new PriorityQueue(20, new AlgoSuiteComparator());
    while (algoSuites.hasNext()) {
      tempAlgo = (ArrayList) algoSuites.next();
      Iterator algorithms = tempAlgo.iterator();
      int i = 0;
      String algorithmName = "";
      while (algorithms.hasNext()) {
        algorithmName = (String) algorithms.next();
        if (algorithmName.equals(encMethod)) {
          i++;
        } else if (algorithmName.equals(asymKW)) {
          i++;
        } else if (algorithmName.equals(digestMethod)) {
          i++;
        }
      }
      if (i > 0) {
        q.add(new AlgoSuite(algorithmName, i));
      }

      /*
            if(i>=2){

               this.suite = new AlgorithmSuite(11);
              try {
                this.suite.setAlgorithmSuite((String)tempAlgo.get(3));
                System.out.println("AlgoSuite : "+(String)tempAlgo.get(3));


              } catch (WSSPolicyException e) {
                e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
              }
              this.isBehaviorCompleted=true;

               System.out.println("Digest Method : " + digestMethod);
               System.out.println("Encryption Method for Data : " + encMethod);
               System.out.println("Encryption Method for Key : " + asymKW);
               break;

            }

            */
    }
    if (!q.isEmpty()) {
      this.suite = new AlgorithmSuite(11);
      try {
        String algoSuiteName = ((AlgoSuite) q.poll()).getSuite();
        this.suite.setAlgorithmSuite(algoSuiteName);
        if (log.isDebugEnabled()) {
          log.debug("AlgoSuite : " + algoSuiteName);
        }
        //  System.out.println("AlgoSuite : "+algoSuiteName);
View Full Code Here

Examples of java.util.PriorityQueue

        if ( capacity == 0 ) {
            return;
        }

        this.queue = new PriorityQueue( capacity,
                                        new Comparator<SimulationStep>() {
                                            public int compare(SimulationStep s1,
                                                               SimulationStep s2) {
                                                return (int) (s1.getDistanceMillis() - s2.getDistanceMillis());
                                            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.