本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.isEmpty()
方法的一些代码示例,展示了MinMaxPriorityQueue.isEmpty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.isEmpty()
方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:isEmpty
暂无
代码示例来源:origin: google/guava
@Override
public E peek() {
return isEmpty() ? null : elementData(0);
}
代码示例来源:origin: google/guava
@CanIgnoreReturnValue
@Override
public E poll() {
return isEmpty() ? null : removeAndGet(0);
}
代码示例来源:origin: google/j2objc
@Override
public E peek() {
return isEmpty() ? null : elementData(0);
}
代码示例来源:origin: google/guava
/**
* Retrieves, but does not remove, the greatest element of this queue, or returns {@code null} if
* the queue is empty.
*/
public E peekLast() {
return isEmpty() ? null : elementData(getMaxElementIndex());
}
代码示例来源:origin: google/guava
/**
* Removes and returns the greatest element of this queue.
*
* @throws NoSuchElementException if the queue is empty
*/
@CanIgnoreReturnValue
public E removeLast() {
if (isEmpty()) {
throw new NoSuchElementException();
}
return removeAndGet(getMaxElementIndex());
}
代码示例来源:origin: google/guava
/**
* Removes and returns the greatest element of this queue, or returns {@code null} if the queue is
* empty.
*/
@CanIgnoreReturnValue
public E pollLast() {
return isEmpty() ? null : removeAndGet(getMaxElementIndex());
}
代码示例来源:origin: apache/hive
@Override
public void processFinal() {
while (!outputs.isEmpty()) {
String row = outputs.removeFirst();
digest.update(row.getBytes());
printDirect(row);
}
printDirect(new String(Base64.encodeBase64(digest.digest())));
digest.reset();
}
}
代码示例来源:origin: google/j2objc
@CanIgnoreReturnValue
@Override
public E poll() {
return isEmpty() ? null : removeAndGet(0);
}
代码示例来源:origin: google/j2objc
/**
* Retrieves, but does not remove, the greatest element of this queue, or returns {@code null} if
* the queue is empty.
*/
public E peekLast() {
return isEmpty() ? null : elementData(getMaxElementIndex());
}
代码示例来源:origin: google/j2objc
/**
* Removes and returns the greatest element of this queue.
*
* @throws NoSuchElementException if the queue is empty
*/
@CanIgnoreReturnValue
public E removeLast() {
if (isEmpty()) {
throw new NoSuchElementException();
}
return removeAndGet(getMaxElementIndex());
}
代码示例来源:origin: wildfly/wildfly
@CanIgnoreReturnValue
@Override
public E poll() {
return isEmpty() ? null : removeAndGet(0);
}
代码示例来源:origin: wildfly/wildfly
/**
* Retrieves, but does not remove, the greatest element of this queue, or returns {@code null} if
* the queue is empty.
*/
public E peekLast() {
return isEmpty() ? null : elementData(getMaxElementIndex());
}
代码示例来源:origin: google/j2objc
/**
* Removes and returns the greatest element of this queue, or returns {@code null} if the queue is
* empty.
*/
@CanIgnoreReturnValue
public E pollLast() {
return isEmpty() ? null : removeAndGet(getMaxElementIndex());
}
代码示例来源:origin: google/guava
public void testCorrectOrdering_mediumHeapsPollFirst() {
for (int attempts = 0; attempts < reduceIterationsIfGwt(5000); attempts++) {
int size = new Random().nextInt(256) + 16;
ArrayList<Integer> elements = createOrderedList(size);
List<Integer> expected = ImmutableList.copyOf(elements);
MinMaxPriorityQueue<Integer> q = MinMaxPriorityQueue.create();
long seed = insertRandomly(elements, q);
while (!q.isEmpty()) {
elements.add(q.pollFirst());
}
assertEqualsUsingSeed(seed, expected, elements);
}
}
代码示例来源:origin: google/guava
public void testCorrectOrdering_mediumHeapsPollLast() {
for (int attempts = 0; attempts < reduceIterationsIfGwt(5000); attempts++) {
int size = new Random().nextInt(256) + 16;
ArrayList<Integer> elements = createOrderedList(size);
List<Integer> expected = ImmutableList.copyOf(elements);
MinMaxPriorityQueue<Integer> q = MinMaxPriorityQueue.create();
long seed = insertRandomly(elements, q);
while (!q.isEmpty()) {
elements.add(0, q.pollLast());
}
assertEqualsUsingSeed(seed, expected, elements);
}
}
代码示例来源:origin: google/guava
public void testCorrectOrdering_smallHeapsPollFirst() {
for (int size = 2; size < 16; size++) {
for (int attempts = 0; attempts < size * (size - 1); attempts++) {
ArrayList<Integer> elements = createOrderedList(size);
List<Integer> expected = ImmutableList.copyOf(elements);
MinMaxPriorityQueue<Integer> q = MinMaxPriorityQueue.create();
long seed = insertRandomly(elements, q);
while (!q.isEmpty()) {
elements.add(q.pollFirst());
}
assertEqualsUsingSeed(seed, expected, elements);
}
}
}
代码示例来源:origin: google/guava
public void testCorrectOrdering_smallHeapsPollLast() {
for (int size = 2; size < 16; size++) {
for (int attempts = 0; attempts < size * (size - 1); attempts++) {
ArrayList<Integer> elements = createOrderedList(size);
List<Integer> expected = ImmutableList.copyOf(elements);
MinMaxPriorityQueue<Integer> q = MinMaxPriorityQueue.create();
long seed = insertRandomly(elements, q);
while (!q.isEmpty()) {
elements.add(0, q.pollLast());
}
assertEqualsUsingSeed(seed, expected, elements);
}
}
}
代码示例来源:origin: google/guava
/** Regression test for bug found in random testing. */
public void testCorrectOrdering_73ElementBug() {
int size = 73;
long seed = 7522346378524621981L;
ArrayList<Integer> elements = createOrderedList(size);
List<Integer> expected = ImmutableList.copyOf(elements);
MinMaxPriorityQueue<Integer> q = MinMaxPriorityQueue.create();
insertRandomly(elements, q, new Random(seed));
assertIntact(q);
while (!q.isEmpty()) {
elements.add(q.pollFirst());
assertIntact(q);
}
assertEqualsUsingSeed(seed, expected, elements);
}
代码示例来源: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
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);
}
}
内容来源于网络,如有侵权,请联系作者删除!