Package java.util

Examples of java.util.PriorityQueue$PriorityQueueSpliterator


        Set<JTag> set = new LinkedHashSet<JTag>();
        set.add(new JTag("Test"));
        set.add(new JTag("Test2"));
        assertEquals(2, set.size());

        PriorityQueue q = new PriorityQueue<JTag>();
        q.add(new JTag("test"));
        q.add(new JTag("pest"));
        assertEquals(2, q.size());
        assertNotNull(q.poll());
        assertNotNull(q.poll());
        assertNull(q.poll());

        // THIS IS UGLY
        set = new TreeSet<JTag>();
        set.add(new JTag("Test"));
        set.add(new JTag("Test2"));
View Full Code Here


        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

        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

      return l_sorted_rules;
    }
   
    private void add_rule(Rule rl){     
      if(heap_rules==null)
        heap_rules = new PriorityQueue(1, Rule.FrequencyComparator);//TODO: initial capacity?
      String sig = rl.get_eng_signature();
      Rule old_rule = (Rule) tbl_eng_rules.get(sig);
      if(old_rule!=null){
        for(int i=0; i< rl.feat_scores.length; i++)
          old_rule.feat_scores[i] += rl.feat_scores[i];
View Full Code Here

        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

      Collections.addAll(allFields, nextClass.getDeclaredFields());
      nextClass = nextClass.getSuperclass();
    }

    ArrayList<CachedField> publicFields = new ArrayList();
    PriorityQueue<CachedField> cachedFields = new PriorityQueue(Math.max(1, allFields.size()), new Comparator<CachedField>() {
      public int compare (CachedField o1, CachedField o2) {
        // Fields are sorted by alpha so the order of the data is known.
        return o1.field.getName().compareTo(o2.field.getName());
      }
    });
    for (int i = 0, n = allFields.size(); i < n; i++) {
      Field field = allFields.get(i);

      int modifiers = field.getModifiers();
      if (Modifier.isTransient(modifiers)) continue;
      if (Modifier.isStatic(modifiers)) continue;
      if (field.isSynthetic() && ignoreSyntheticFields) continue;

      if (!field.isAccessible()) {
        if (!setFieldsAsAccessible) continue;
        try {
          field.setAccessible(true);
        } catch (AccessControlException ex) {
          continue;
        }
      }

      CachedField cachedField = new CachedField();
      cachedField.field = field;
      if (fieldsCanBeNull)
        cachedField.canBeNull = !field.isAnnotationPresent(NotNull.class);
      else
        cachedField.canBeNull = false;

      // Always use the same serializer for this field if the field's class is final.
      Class fieldClass = field.getType();
      if (isFinal(fieldClass)) cachedField.fieldClass = fieldClass;

      cachedFields.add(cachedField);
      if (Modifier.isPublic(modifiers) && Modifier.isPublic(fieldClass.getModifiers())) publicFields.add(cachedField);
    }

    if (!Util.isAndroid && Modifier.isPublic(type.getModifiers()) && !publicFields.isEmpty()) {
      // Use ReflectASM for any public fields.
      try {
        access = FieldAccess.get(type);
        for (int i = 0, n = publicFields.size(); i < n; i++) {
          CachedField cachedField = publicFields.get(i);
          cachedField.accessIndex = ((FieldAccess)access).getIndex(cachedField.field.getName());
        }
      } catch (AccessControlException ignored) {
      }
    }

    int fieldCount = cachedFields.size();
    fields = new CachedField[fieldCount];
    for (int i = 0; i < fieldCount; i++)
      fields[i] = cachedFields.poll();
  }
View Full Code Here

      Collections.addAll(allFields, nextClass.getDeclaredFields());
      nextClass = nextClass.getSuperclass();
    }

    ArrayList<CachedField> publicFields = new ArrayList();
    PriorityQueue<CachedField> cachedFields = new PriorityQueue(Math.max(1, allFields.size()), new Comparator<CachedField>() {
      public int compare (CachedField o1, CachedField o2) {
        // Fields are sorted by alpha so the order of the data is known.
        return o1.field.getName().compareTo(o2.field.getName());
      }
    });
    for (int i = 0, n = allFields.size(); i < n; i++) {
      Field field = allFields.get(i);

      int modifiers = field.getModifiers();
      if (Modifier.isTransient(modifiers)) continue;
      if (Modifier.isStatic(modifiers)) continue;
      if (field.isSynthetic()) continue;

      if (!field.isAccessible()) {
        if (!setFieldsAsAccessible) continue;
        try {
          field.setAccessible(true);
        } catch (AccessControlException ex) {
          continue;
        }
      }

      CachedField cachedField = new CachedField();
      cachedField.field = field;
      if (fieldsCanBeNull)
        cachedField.canBeNull = !field.isAnnotationPresent(NotNull.class);
      else
        cachedField.canBeNull = false;

      // Always use the same serializer for this field if the field's class is final.
      Class fieldClass = field.getType();
      if (isFinal(fieldClass)) cachedField.fieldClass = fieldClass;

      cachedFields.add(cachedField);
      if (Modifier.isPublic(modifiers) && Modifier.isPublic(fieldClass.getModifiers())) publicFields.add(cachedField);
    }

    if (!Util.isAndroid && Modifier.isPublic(type.getModifiers()) && !publicFields.isEmpty()) {
      // Use ReflectASM for any public fields.
      try {
        access = FieldAccess.get(type);
        for (int i = 0, n = publicFields.size(); i < n; i++) {
          CachedField cachedField = publicFields.get(i);
          cachedField.accessIndex = ((FieldAccess)access).getIndex(cachedField.field.getName());
        }
      } catch (AccessControlException ignored) {
      }
    }

    int fieldCount = cachedFields.size();
    fields = new CachedField[fieldCount];
    for (int i = 0; i < fieldCount; i++)
      fields[i] = cachedFields.poll();
  }
View Full Code Here

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

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

            _reverse = reverse;
        }

        @Override
        public PriorityQueue init(Object batchId, TridentCollector collector) {
            return new PriorityQueue(_n, new Comparator<TridentTuple>() {
                @Override
                public int compare(TridentTuple t1, TridentTuple t2) {
                    Comparable c1 = (Comparable) t1.getValueByField(_sortField);
                    Comparable c2 = (Comparable) t2.getValueByField(_sortField);
                    int ret = c1.compareTo(c2);
View Full Code Here

        public int compare(PeekingIterator paramAnonymousPeekingIterator1, PeekingIterator paramAnonymousPeekingIterator2)
        {
          return Iterators.MergingIterator.this.comparator.compare(paramAnonymousPeekingIterator1.peek(), paramAnonymousPeekingIterator2.peek());
        }
      };
      this.queue = new PriorityQueue(2, local1);
      Iterator localIterator1 = paramIterable.iterator();
      while (localIterator1.hasNext())
      {
        Iterator localIterator2 = (Iterator)localIterator1.next();
        if (localIterator2.hasNext())
View Full Code Here

TOP

Related Classes of java.util.PriorityQueue$PriorityQueueSpliterator

Copyright © 2018 www.massapicom. 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.