本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.poll()
方法的一些代码示例,展示了MinMaxPriorityQueue.poll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.poll()
方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:poll
[英]Removes and returns the least element of this queue, or returns null if the queue is empty.
[中]移除并返回此队列的最小元素,如果队列为空,则返回null。
代码示例来源:origin: google/guava
/**
* Removes and returns the least element of this queue, or returns {@code null} if the queue is
* empty.
*/
@CanIgnoreReturnValue
public E pollFirst() {
return poll();
}
代码示例来源:origin: google/guava
/** Regression test for b/4124577 */
public void testRegression_dataCorruption() {
int size = 8;
List<Integer> expected = createOrderedList(size);
MinMaxPriorityQueue<Integer> q = MinMaxPriorityQueue.create(expected);
List<Integer> contents = Lists.newArrayList(expected);
List<Integer> elements = Lists.newArrayListWithCapacity(size);
while (!q.isEmpty()) {
assertThat(q).containsExactlyElementsIn(contents);
Integer next = q.pollFirst();
contents.remove(next);
assertThat(q).containsExactlyElementsIn(contents);
for (int i = 0; i <= size; i++) {
q.add(i);
contents.add(i);
assertThat(q).containsExactlyElementsIn(contents);
q.add(next);
contents.add(next);
assertThat(q).containsExactlyElementsIn(contents);
q.remove(i);
assertTrue(contents.remove(Integer.valueOf(i)));
assertThat(q).containsExactlyElementsIn(contents);
assertEquals(next, q.poll());
contents.remove(next);
assertThat(q).containsExactlyElementsIn(contents);
}
elements.add(next);
}
assertEquals(expected, elements);
}
代码示例来源:origin: google/guava
removeMinFromReplica(replica, mmHeap.poll());
} else {
removeMaxFromReplica(replica, mmHeap.pollLast());
代码示例来源:origin: google/j2objc
/**
* Removes and returns the least element of this queue, or returns {@code null} if the queue is
* empty.
*/
@CanIgnoreReturnValue
public E pollFirst() {
return poll();
}
代码示例来源:origin: google/guava
public void testExhaustive_pollAndPush() {
int size = 5;
List<Integer> expected = createOrderedList(size);
for (Collection<Integer> perm : Collections2.permutations(expected)) {
MinMaxPriorityQueue<Integer> q = MinMaxPriorityQueue.create(perm);
List<Integer> elements = Lists.newArrayListWithCapacity(size);
while (!q.isEmpty()) {
Integer next = q.pollFirst();
for (int i = 0; i <= size; i++) {
assertTrue(q.add(i));
assertTrue(q.add(next));
assertTrue(q.remove(i));
assertEquals(next, q.poll());
}
elements.add(next);
}
assertEqualsUsingStartedWith(perm, expected, elements);
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Removes and returns the least element of this queue, or returns {@code null} if the queue is
* empty.
*/
@CanIgnoreReturnValue
public E pollFirst() {
return poll();
}
代码示例来源:origin: apache/incubator-gobblin
pQueue.poll();
pQueue.add(lightestMultiWorkUnit);
} else {
代码示例来源:origin: apache/incubator-gobblin
MultiWorkUnit lightestMultiWorkUnit = pQueue.poll();
addWorkUnitToMultiWorkUnit(group, lightestMultiWorkUnit);
pQueue.add(lightestMultiWorkUnit);
代码示例来源:origin: google/guava
public void testSmallMinHeap() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.add(1);
mmHeap.add(3);
mmHeap.add(2);
assertEquals(1, (int) mmHeap.peek());
assertEquals(1, (int) mmHeap.poll());
assertEquals(3, (int) mmHeap.peekLast());
assertEquals(2, (int) mmHeap.peek());
assertEquals(2, (int) mmHeap.poll());
assertEquals(3, (int) mmHeap.peekLast());
assertEquals(3, (int) mmHeap.peek());
assertEquals(3, (int) mmHeap.poll());
assertNull(mmHeap.peekLast());
assertNull(mmHeap.peek());
assertNull(mmHeap.poll());
}
代码示例来源:origin: apache/phoenix
@Override
public T poll() {
initMergedQueue();
if (mergedQueue != null && !mergedQueue.isEmpty()) {
MappedByteBufferSegmentQueue<T> queue = mergedQueue.poll();
T re = queue.poll();
if (queue.peek() != null) {
mergedQueue.add(queue);
}
return re;
}
return null;
}
代码示例来源:origin: com.google.guava/guava-jdk5
/**
* Removes and returns the least element of this queue, or returns {@code
* null} if the queue is empty.
*/
public E pollFirst() {
return poll();
}
代码示例来源:origin: org.sonatype.sisu/sisu-guava
/**
* Removes and returns the least element of this queue, or returns {@code
* null} if the queue is empty.
*/
public E pollFirst() {
return poll();
}
代码示例来源:origin: com.n3twork.druid/druid-processing
@Override
public T next()
{
return rows.poll();
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
/**
* Removes and returns the least element of this queue, or returns {@code
* null} if the queue is empty.
*/
public E pollFirst() {
return poll();
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Removes and returns the least element of this queue, or returns {@code
* null} if the queue is empty.
*/
public E pollFirst() {
return poll();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
/**
* Removes and returns the least element of this queue, or returns {@code
* null} if the queue is empty.
*/
public E pollFirst() {
return poll();
}
代码示例来源:origin: com.diffplug.guava/guava-collect
/**
* Removes and returns the least element of this queue, or returns {@code
* null} if the queue is empty.
*/
public E pollFirst() {
return poll();
}
代码示例来源:origin: forcedotcom/phoenix
ResultEntry re = results.poll();
if (re == null) {
reachedEnd();
代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger
/**
* Removes and returns the least element of this queue, or returns {@code null} if the queue is
* empty.
*/
@CanIgnoreReturnValue
public E pollFirst() {
return poll();
}
代码示例来源:origin: uk.co.nichesolutions.presto/presto-main
private Iterator<Block[]> build()
{
ImmutableList.Builder<Block[]> sortedRows = ImmutableList.builder();
while (!candidateRows.isEmpty()) {
sortedRows.add(candidateRows.poll());
}
return sortedRows.build().iterator();
}
内容来源于网络,如有侵权,请联系作者删除!