本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.peek()
方法的一些代码示例,展示了MinMaxPriorityQueue.peek()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.peek()
方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:peek
[英]Retrieves, but does not remove, the least element of this queue, or returns null if the queue is empty.
[中]检索但不删除此队列的最小元素,如果队列为空,则返回null。
代码示例来源:origin: google/guava
/**
* Retrieves, but does not remove, the least element of this queue, or returns {@code null} if the
* queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: google/guava
public void testCreateWithOrdering() {
MinMaxPriorityQueue<String> mmHeap =
MinMaxPriorityQueue.orderedBy(Ordering.natural().reverse()).create();
Collections.addAll(mmHeap, "foo", "bar", "foobar", "barfoo", "larry", "sergey", "eric");
assertTrue("Heap is not intact initially", mmHeap.isIntact());
assertEquals("sergey", mmHeap.peek());
assertEquals("bar", mmHeap.peekLast());
}
代码示例来源:origin: google/j2objc
/**
* Retrieves, but does not remove, the least element of this queue, or returns {@code null} if the
* queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: google/guava
public void testCreateWithCapacityAndOrdering() {
MinMaxPriorityQueue<Integer> mmHeap =
MinMaxPriorityQueue.orderedBy(Ordering.natural().reverse()).expectedSize(5).create();
Collections.addAll(mmHeap, 1, 7, 2, 56, 2, 5, 23, 68, 0, 3);
assertTrue("Heap is not intact initially", mmHeap.isIntact());
assertEquals(68, (int) mmHeap.peek());
assertEquals(0, (int) mmHeap.peekLast());
}
代码示例来源:origin: wildfly/wildfly
/**
* Retrieves, but does not remove, the least element of this queue, or returns {@code null} if the
* queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源: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/incubator-gobblin
MultiWorkUnit lightestMultiWorkUnit = pQueue.peek();
long weight = Math.max(1, weighter.weight(workUnit));
long multiWorkUnitWeight = getMultiWorkUnitWeight(lightestMultiWorkUnit);
代码示例来源:origin: google/guava
public void testSmall() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.add(1);
mmHeap.add(4);
mmHeap.add(2);
mmHeap.add(3);
assertEquals(4, (int) mmHeap.pollLast());
assertEquals(3, (int) mmHeap.peekLast());
assertEquals(3, (int) mmHeap.pollLast());
assertEquals(1, (int) mmHeap.peek());
assertEquals(2, (int) mmHeap.peekLast());
assertEquals(2, (int) mmHeap.pollLast());
assertEquals(1, (int) mmHeap.peek());
assertEquals(1, (int) mmHeap.peekLast());
assertEquals(1, (int) mmHeap.pollLast());
assertNull(mmHeap.peek());
assertNull(mmHeap.peekLast());
assertNull(mmHeap.pollLast());
}
代码示例来源:origin: apache/phoenix
@Override
public T peek() {
initMergedQueue();
if (mergedQueue != null && !mergedQueue.isEmpty()) {
return mergedQueue.peek().peek();
}
return null;
}
代码示例来源:origin: google/guava
public void testRemoveFromStringHeap() {
MinMaxPriorityQueue<String> mmHeap = MinMaxPriorityQueue.expectedSize(5).create();
Collections.addAll(mmHeap, "foo", "bar", "foobar", "barfoo", "larry", "sergey", "eric");
assertTrue("Heap is not intact initially", mmHeap.isIntact());
assertEquals("bar", mmHeap.peek());
assertEquals("sergey", mmHeap.peekLast());
assertEquals(7, mmHeap.size());
assertTrue("Could not remove larry", mmHeap.remove("larry"));
assertEquals(6, mmHeap.size());
assertFalse("heap contains larry which has been removed", mmHeap.contains("larry"));
assertTrue("heap does not contain sergey", mmHeap.contains("sergey"));
assertTrue("Could not remove larry", mmHeap.removeAll(Lists.newArrayList("sergey", "eric")));
assertFalse("Could remove nikesh which is not in the heap", mmHeap.remove("nikesh"));
assertEquals(4, mmHeap.size());
}
代码示例来源:origin: com.google.guava/guava-jdk5
/**
* Retrieves, but does not remove, the least element of this queue, or returns
* {@code null} if the queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: com.atlassian.bundles/guava
/**
* Retrieves, but does not remove, the least element of this queue, or returns
* {@code null} if the queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: Nextdoor/bender
/**
* Retrieves, but does not remove, the least element of this queue, or returns
* {@code null} if the queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
/**
* Retrieves, but does not remove, the least element of this queue, or returns
* {@code null} if the queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: com.diffplug.guava/guava-collect
/**
* Retrieves, but does not remove, the least element of this queue, or returns
* {@code null} if the queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: org.hudsonci.lib.guava/guava
/**
* Retrieves, but does not remove, the least element of this queue, or returns
* {@code null} if the queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Retrieves, but does not remove, the least element of this queue, or returns
* {@code null} if the queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics
/**
* Retrieves, but does not remove, the least element of this queue, or returns
* {@code null} if the queue is empty.
*/
public E peekFirst() {
return peek();
}
代码示例来源:origin: com.aliyun.phoenix/ali-phoenix-core
@Override
public T peek() {
initMergedQueue();
if (mergedQueue != null && !mergedQueue.isEmpty()) {
return mergedQueue.peek().peek();
}
return null;
}
代码示例来源:origin: org.apache.phoenix/phoenix-core
@Override
public T peek() {
initMergedQueue();
if (mergedQueue != null && !mergedQueue.isEmpty()) {
return mergedQueue.peek().peek();
}
return null;
}
内容来源于网络,如有侵权,请联系作者删除!