本文整理了Java中java.util.TreeSet.pollFirst()
方法的一些代码示例,展示了TreeSet.pollFirst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreeSet.pollFirst()
方法的具体详情如下:
包路径:java.util.TreeSet
类名称:TreeSet
方法名:pollFirst
暂无
代码示例来源:origin: apache/ignite
/**
* @return Retrieves the minimum update counter task from queue.
*/
private Item poll() {
return queue.pollFirst();
}
代码示例来源:origin: apache/flink
@Nullable
@Override
public byte[] pollFirst() {
return !isEmpty() ? treeSet.pollFirst() : null;
}
代码示例来源:origin: cmusphinx/sphinx4
public void add(T item) {
items.add(item);
if (items.size() > maxSize)
items.pollFirst();
}
代码示例来源:origin: atomix/atomix
@Override
public E pollFirst() {
return set().pollFirst();
}
代码示例来源:origin: apache/storm
private synchronized void trimHead() {
if (offsets.size() <= 1) {
return;
}
FileOffset head = offsets.first();
FileOffset head2 = offsets.higher(head);
if (head.isNextOffset(head2)) {
offsets.pollFirst();
trimHead();
}
return;
}
代码示例来源:origin: apache/kafka
sortedPartitions.add(sortedAllPartitions.pollFirst());
代码示例来源:origin: apache/storm
@Override
public EventDataWrap receive() {
if (pending.size() >= config.getMaxPendingMsgsPerPartition()) {
return null;
}
EventDataWrap eventDatawrap;
if (toResend.isEmpty()) {
eventDatawrap = receiver.receive();
} else {
eventDatawrap = toResend.pollFirst();
}
if (eventDatawrap != null) {
lastOffset = eventDatawrap.getMessageId().getOffset();
pending.put(lastOffset, eventDatawrap);
}
return eventDatawrap;
}
代码示例来源:origin: apache/kylin
synchronized (taskPending) {
while (task == null && taskHasNoException()) {
task = taskPending.pollFirst();
if (task == null)
taskPending.wait(60000);
代码示例来源: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: 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: org.apache.lucene/lucene-core
path = queue.pollFirst();
代码示例来源:origin: sixt/ja-micro
private void processNext(int partition) {
TreeSet<ConsumerRecord<String, String>> pQueue = partitionQueue.get(partition);
if (pQueue != null && !pQueue.isEmpty()) {
ConsumerRecord<String, String> record = pQueue.first();
messageExecutor.execute(record);
inProgress.put(partition, record);
pQueue.pollFirst();
}
}
}
代码示例来源:origin: square/gifencoder
@Override public Set<Color> quantize(Multiset<Color> originalColors, int maxColorCount) {
TreeSet<Cluster> clusters = new TreeSet<>(new ClusterSpreadComparator());
clusters.add(new Cluster(originalColors));
while (clusters.size() < maxColorCount) {
Cluster clusterWithLargestSpread = clusters.pollFirst();
clusters.addAll(clusterWithLargestSpread.split());
}
Set<Color> clusterCentroids = new HashSet<>();
for (Cluster cluster : clusters) {
clusterCentroids.add(Color.getCentroid(cluster.colors));
}
return clusterCentroids;
}
代码示例来源: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: facebook/jcommon
@Override
public synchronized void add(T key, long count) {
Preconditions.checkNotNull(key, "key can't be null");
Preconditions.checkArgument(count >= 0, "count to add must be non-negative, got %s", count);
if (count == 0) {
return;
}
Long currentCount = counts.get(key);
if (currentCount == null) {
currentCount = 0L;
}
long updatedCount = currentCount + count;
counts.put(key, updatedCount);
if (topKeys.contains(key)) {
topPairs.remove(new ComparablePair<Long, T>(currentCount, key));
topPairs.add(new ComparablePair<Long, T>(updatedCount, key));
} else if (topPairs.size() < k) {
topPairs.add(new ComparablePair<Long, T>(updatedCount, key));
topKeys.add(key);
smallestTopCount = Math.min(smallestTopCount, updatedCount);
} else if (updatedCount > smallestTopCount) {
ComparablePair<Long, T> smallestTopPair = topPairs.pollFirst();
topKeys.remove(smallestTopPair.getSecond());
topPairs.add(new ComparablePair<Long, T>(updatedCount, key));
topKeys.add(key);
smallestTopCount = topPairs.first().getFirst();
}
}
代码示例来源:origin: linkedin/indextank-engine
Head<K> currentElement = heads.pollFirst();
if (currentElement == null) {
return endOfData();
Head<K> newElement = heads.pollFirst();
nextsToDo.set(newElement.position);
代码示例来源:origin: facebook/jcommon
@Override
public synchronized void add(Integer key, long count) {
Preconditions.checkNotNull(key, "key can't be null");
Preconditions.checkElementIndex(key, counts.length, "key");
Preconditions.checkArgument(count >= 0, "count to add must be non-negative, got %s", count);
if (count == 0) {
return;
}
long currentCount = counts[key];
counts[key] += count;
if (isInTop[key]) {
topPairs.remove(new ComparablePair<Long, Integer>(currentCount, key));
topPairs.add(new ComparablePair<Long, Integer>(counts[key], key));
} else if (topPairs.size() < k) {
topPairs.add(new ComparablePair<Long, Integer>(counts[key], key));
isInTop[key] = true;
smallestTopCount = Math.min(smallestTopCount, counts[key]);
} else if (counts[key] > smallestTopCount) {
ComparablePair<Long, Integer> smallestTopPair = topPairs.pollFirst();
isInTop[smallestTopPair.getSecond()] = false;
topPairs.add(new ComparablePair<Long, Integer>(counts[key], key));
isInTop[key] = true;
smallestTopCount = topPairs.first().getFirst();
}
}
代码示例来源:origin: dermotte/LIRE
flag = true;
while (flag && (tmpDocs.size() > 0)){
simpleResult = tmpDocs.pollFirst();
if (this.docs.size() < maxHits) {
this.docs.add(simpleResult);
代码示例来源:origin: dermotte/LIRE
flag = true;
while (flag && (tmpDocs.size() > 0)){
simpleResult = tmpDocs.pollFirst();
if (this.docs.size() < maxHits) {
this.docs.add(simpleResult);
代码示例来源:origin: dermotte/LIRE
flag = true;
while (flag && (tmpDocs.size() > 0)){
simpleResult = tmpDocs.pollFirst();
if (this.docs.size() < maxHits) {
this.docs.add(simpleResult);
内容来源于网络,如有侵权,请联系作者删除!