java.util.TreeSet.pollLast()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(133)

本文整理了Java中java.util.TreeSet.pollLast()方法的一些代码示例,展示了TreeSet.pollLast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeSet.pollLast()方法的具体详情如下:
包路径:java.util.TreeSet
类名称:TreeSet
方法名:pollLast

TreeSet.pollLast介绍

暂无

代码示例

代码示例来源:origin: cmusphinx/sphinx4

public T poll() {
  return items.pollLast();
}

代码示例来源:origin: apache/flink

@Nullable
@Override
public byte[] pollLast() {
  return !isEmpty() ? treeSet.pollLast() : null;
}

代码示例来源:origin: atomix/atomix

@Override
public E pollLast() {
 return set().pollLast();
}

代码示例来源:origin: apache/kafka

String consumer = sortedConsumers.pollLast();
List<TopicPartition> remainingPartitions = assignments.get(consumer);
if (!remainingPartitions.isEmpty()) {

代码示例来源:origin: alibaba/jstorm

private TransactionState getLastestCommittedState(int taskId) {
  TransactionState ret = null;
  String componentId = context.getComponentId(taskId);
  TreeSet<Long> batchIds = new TreeSet<Long>(inprogressSnapshots.keySet());
  Long batchId = null;
  while ((batchId = batchIds.pollLast()) != null) {
    BatchStateTracker tracker = inprogressSnapshots.get(batchId);
    Map<Integer, TransactionState> states = tracker.getComponentStates(componentId);
    if (states != null && (ret = states.get(taskId)) != null)
      break;
  }
  return ret;
}

代码示例来源:origin: apache/hive

return false; // The tasks from now on are more important than the candidate.
TaskInfo taskInfo = atPriority.pollLast();
if (taskInfo != null) {
 synchronized (taskInfo) {

代码示例来源:origin: apache/usergrid

static TreeSet<UUID> add( TreeSet<UUID> a, UUID uuid, boolean reversed, int limit ) {
  if ( a == null ) {
    a = new TreeSet<UUID>( new UUIDComparator() );
  }
  if ( uuid == null ) {
    return a;
  }
  // if we have less than the limit, just add it
  if ( a.size() < limit ) {
    a.add( uuid );
  }
  else if ( reversed ) {
    // if reversed, we want to add more recent messages
    // and eject the oldest
    if ( UUIDComparator.staticCompare( uuid, a.first() ) > 0 ) {
      a.pollFirst();
      a.add( uuid );
    }
  }
  else {
    // add older messages and eject the newset
    if ( UUIDComparator.staticCompare( uuid, a.last() ) < 0 ) {
      a.pollLast();
      a.add( uuid );
    }
  }
  return a;
}

代码示例来源:origin: kairosdb/kairosdb

public T nextElement()
  {
    TreeValue<T> value;
    if (m_order == Order.ASC)
      value = m_treeSet.pollFirst();
    else
      value = m_treeSet.pollLast();

    if (value == null)
      return (null);

    T ret = value.getValue();

    if (value.getIterator().hasNext())
    {
      value.setValue(value.getIterator().next());
      m_treeSet.add(value);
    }

    return (ret);
  }
}

代码示例来源:origin: NLPchina/nlp-lang

treeSet.pollLast();

代码示例来源:origin: org.apache.lucene/lucene-core

queue.add(newPath);
if (queue.size() == maxQueueDepth+1) {
 queue.pollLast();

代码示例来源:origin: linkedin/indextank-engine

public static <T> SortedSet<T> sortTopN(Iterable<T> iterable, int n,
    Comparator<T> comparator) {
  TreeSet<T> r = Sets.newTreeSet(comparator);
  for (T t : iterable) {
    r.add(t);
    if (r.size() > n) {
      r.pollLast();
    }
  }
  return r;
}

代码示例来源:origin: dermotte/LIRE

private static TreeSet<Result> getResults(GlobalFeature feature, int queryLength, int lengthOfPostingList) {
  ArrayList<GlobalFeature> l = referencePoints.get(feature.getClass().getName());
  // break if the feature is not indexed ...
  if (l == null) return null;
  TreeSet<Result> results = new TreeSet<>();
  double maxDistance = Double.MAX_VALUE;
  double distance;
  for (int i = 0; i < l.size(); i++) {
    GlobalFeature f = l.get(i);
    distance = f.getDistance(feature);
    if (results.size() < lengthOfPostingList) {
      results.add(new Result(distance, i));
      maxDistance = l.get(results.last().index).getDistance(feature);
    } else if (distance < maxDistance) {
      results.add(new Result(distance, i));
      maxDistance = distance;
      if (results.size() > lengthOfPostingList) {
        results.pollLast();
      }
    }
  }
  return results;
}

代码示例来源:origin: dermotte/LIRE

private static TreeSet<Result> getResults(GlobalFeature feature, int queryLength, int lengthOfPostingList) {
  ArrayList<GlobalFeature> l = referencePoints.get(feature.getClass().getName());
  // break if the feature is not indexed ...
  if (l == null) return null;
  TreeSet<Result> results = new TreeSet<>();
  double maxDistance = Double.MAX_VALUE;
  double distance;
  for (int i = 0; i < l.size(); i++) {
    GlobalFeature f = l.get(i);
    distance = f.getDistance(feature);
    if (results.size() < lengthOfPostingList) {
      results.add(new Result(distance, i));
      maxDistance = l.get(results.last().index).getDistance(feature);
    } else if (distance < maxDistance) {
      results.add(new Result(distance, i));
      maxDistance = distance;
      if (results.size() > lengthOfPostingList) {
        results.pollLast();
      }
    }
  }
  return results;
}

代码示例来源:origin: uber/chaperone

private static Set<InstanceTopicPartitionHolder> balanceAssignment(
  TreeSet<InstanceTopicPartitionHolder> orderedSet) {
 while (!isAssignmentBalanced(orderedSet)) {
  InstanceTopicPartitionHolder lowestInstance = orderedSet.pollFirst();
  InstanceTopicPartitionHolder highestInstance = orderedSet.pollLast();
  TopicPartition tpi = highestInstance.getServingTopicPartitionSet().iterator().next();
  highestInstance.removeTopicPartition(tpi);
  lowestInstance.addTopicPartition(tpi);
  orderedSet.add(lowestInstance);
  orderedSet.add(highestInstance);
 }
 return orderedSet;
}

代码示例来源:origin: dermotte/LIRE

localDocs.pollLast();

代码示例来源:origin: dermotte/LIRE

localDocs.pollLast();

代码示例来源:origin: dermotte/LIRE

localDocs.pollLast();

代码示例来源:origin: dermotte/LIRE

localDocs.pollLast();

代码示例来源:origin: dermotte/LIRE

localDocs.pollLast();

代码示例来源:origin: dermotte/LIRE

localDocs.pollLast();

相关文章