本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.addAll()
方法的一些代码示例,展示了MinMaxPriorityQueue.addAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.addAll()
方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:addAll
暂无
代码示例来源:origin: apache/incubator-druid
/**
* This method is unused, but ScalingStats is {@link PublicApi}, so we cannot remove it.
* TODO test this method (it will "count" as usage)
*/
@SuppressWarnings("unused")
public void addAll(ScalingStats stats)
{
synchronized (lock) {
synchronized (stats.lock) {
recentEvents.addAll(stats.recentEvents);
}
}
}
代码示例来源:origin: google/guava
public void testIteratorPastEndException() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(1, 2));
Iterator<Integer> it = mmHeap.iterator();
assertTrue("Iterator has reached end prematurely", it.hasNext());
it.next();
it.next();
try {
it.next();
fail("No exception thrown when iterating past end of heap");
} catch (NoSuchElementException expected) {
}
}
代码示例来源:origin: google/guava
public void testIteratorConcurrentModification() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(1, 2, 3, 4));
Iterator<Integer> it = mmHeap.iterator();
assertTrue("Iterator has reached end prematurely", it.hasNext());
it.next();
it.next();
mmHeap.remove(4);
try {
it.next();
fail("No exception thrown when iterating a modified heap");
} catch (ConcurrentModificationException expected) {
}
}
代码示例来源:origin: apache/incubator-pinot
completedServersQueue.addAll(polledServers);
if (chosenServer == null) {
throw new IllegalStateException("Could not find server to relocate segment");
代码示例来源:origin: apache/incubator-pinot
MinMaxPriorityQueue<Map.Entry<String, Integer>> completedServersQueue =
MinMaxPriorityQueue.orderedBy(comparator).maximumSize(completedServers.size()).create();
completedServersQueue.addAll(completedServerToNumSegments.entrySet());
代码示例来源:origin: google/guava
mmHeap.addAll(
Lists.newArrayList(1, 20, 1000, 2, 3, 30, 40, 10, 11, 12, 13, 200, 300, 500, 400));
assertTrue("Heap is not intact initially", mmHeap.isIntact());
代码示例来源:origin: google/guava
/** This tests a more obscure special case, but otherwise similar to above. */
public void testInvalidatingRemove2() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
List<Integer> values =
Lists.newArrayList(
1, 20, 1000, 2, 3, 30, 40, 10, 11, 12, 13, 300, 400, 500, 600, 4, 5, 6, 7, 8, 9, 4, 5,
200, 250);
mmHeap.addAll(values);
assertEquals(25, mmHeap.size());
assertTrue("Heap is not intact initially", mmHeap.isIntact());
mmHeap.remove(2);
assertEquals(24, mmHeap.size());
assertTrue("Heap is not intact after remove()", mmHeap.isIntact());
values.removeAll(Lists.newArrayList(2));
assertEquals(values.size(), mmHeap.size());
assertTrue(values.containsAll(mmHeap));
assertTrue(mmHeap.containsAll(values));
}
代码示例来源:origin: google/guava
public void testIteratorInvalidatingIteratorRemove() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(1, 20, 100, 2, 3, 30, 40));
assertEquals(7, mmHeap.size());
assertTrue("Heap is not intact initially", mmHeap.isIntact());
代码示例来源:origin: google/guava
/**
* This tests a special case of the removeAt() call. Moving an element sideways on the heap could
* break the invariants. Sometimes we need to bubble an element up instead of trickling down. See
* implementation.
*/
public void testInvalidatingRemove() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(
Lists.newArrayList(1, 20, 1000, 2, 3, 30, 40, 10, 11, 12, 13, 300, 400, 500, 600));
assertEquals(15, mmHeap.size());
assertTrue("Heap is not intact initially", mmHeap.isIntact());
mmHeap.remove(12);
assertEquals(14, mmHeap.size());
assertTrue("Heap is not intact after remove()", mmHeap.isIntact());
}
代码示例来源:origin: google/guava
public void testRemove() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(1, 2, 3, 4, 47, 1, 5, 3, 0));
assertTrue("Heap is not intact initally", mmHeap.isIntact());
assertEquals(9, mmHeap.size());
mmHeap.remove(5);
assertEquals(8, mmHeap.size());
assertTrue("Heap is not intact after remove()", mmHeap.isIntact());
assertEquals(47, (int) mmHeap.pollLast());
assertEquals(4, (int) mmHeap.pollLast());
mmHeap.removeAll(Lists.newArrayList(2, 3));
assertEquals(3, mmHeap.size());
assertTrue("Heap is not intact after removeAll()", mmHeap.isIntact());
}
代码示例来源:origin: google/guava
public void testContains() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(1, 1, 2));
assertEquals(3, mmHeap.size());
assertFalse("Heap does not contain null", mmHeap.contains(null));
assertFalse("Heap does not contain 3", mmHeap.contains(3));
assertFalse("Heap does not contain 3", mmHeap.remove(3));
assertEquals(3, mmHeap.size());
assertTrue("Heap is not intact after remove()", mmHeap.isIntact());
assertTrue("Heap contains two 1's", mmHeap.contains(1));
assertTrue("Heap contains two 1's", mmHeap.remove(1));
assertTrue("Heap contains 1", mmHeap.contains(1));
assertTrue("Heap contains 1", mmHeap.remove(1));
assertFalse("Heap does not contain 1", mmHeap.contains(1));
assertTrue("Heap contains 2", mmHeap.remove(2));
assertEquals(0, mmHeap.size());
assertFalse("Heap does not contain anything", mmHeap.contains(1));
assertFalse("Heap does not contain anything", mmHeap.remove(2));
}
代码示例来源:origin: org.danilopianini/boilerplate
@Override
public BinaryOperator<MinMaxPriorityQueue<T>> combiner() {
return (a, b) -> {
a.addAll(b);
return a;
};
}
代码示例来源:origin: org.danilopianini/stream-goodies
@Override
public BinaryOperator<MinMaxPriorityQueue<T>> combiner() {
return (a, b) -> {
a.addAll(b);
return a;
};
}
代码示例来源:origin: io.druid/druid-indexing-service
public void addAll(ScalingStats stats)
{
synchronized (lock) {
synchronized (stats.lock) {
recentEvents.addAll(stats.recentEvents);
}
}
}
代码示例来源:origin: org.apache.druid/druid-indexing-service
/**
* This method is unused, but ScalingStats is {@link PublicApi}, so we cannot remove it.
* TODO test this method (it will "count" as usage)
*/
@SuppressWarnings("unused")
public void addAll(ScalingStats stats)
{
synchronized (lock) {
synchronized (stats.lock) {
recentEvents.addAll(stats.recentEvents);
}
}
}
代码示例来源:origin: com.google.guava/guava-tests
public void testIteratorPastEndException() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(1, 2));
Iterator<Integer> it = mmHeap.iterator();
assertTrue("Iterator has reached end prematurely", it.hasNext());
it.next();
it.next();
try {
it.next();
fail("No exception thrown when iterating past end of heap");
} catch (NoSuchElementException expected) {
}
}
代码示例来源:origin: com.google.guava/guava-tests
public void testIteratorConcurrentModification() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(1, 2, 3, 4));
Iterator<Integer> it = mmHeap.iterator();
assertTrue("Iterator has reached end prematurely", it.hasNext());
it.next();
it.next();
mmHeap.remove(4);
try {
it.next();
fail("No exception thrown when iterating a modified heap");
} catch (ConcurrentModificationException expected) {
}
}
代码示例来源:origin: com.google.guava/guava-tests
/**
* This tests a more obscure special case, but otherwise similar to above.
*/
public void testInvalidatingRemove2() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
List<Integer> values = Lists.newArrayList(
1, 20, 1000, 2, 3, 30, 40, 10, 11, 12, 13, 300, 400, 500, 600, 4, 5,
6, 7, 8, 9, 4, 5, 200, 250);
mmHeap.addAll(values);
assertEquals(25, mmHeap.size());
assertTrue("Heap is not intact initially", mmHeap.isIntact());
mmHeap.remove(2);
assertEquals(24, mmHeap.size());
assertTrue("Heap is not intact after remove()", mmHeap.isIntact());
values.removeAll(Lists.newArrayList(2));
assertEquals(values.size(), mmHeap.size());
assertTrue(values.containsAll(mmHeap));
assertTrue(mmHeap.containsAll(values));
}
代码示例来源:origin: com.google.guava/guava-tests
/**
* This tests a special case of the removeAt() call. Moving an element
* sideways on the heap could break the invariants. Sometimes we need to
* bubble an element up instead of trickling down. See implementation.
*/
public void testInvalidatingRemove() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(
1, 20, 1000, 2, 3, 30, 40, 10, 11, 12, 13, 300, 400, 500, 600));
assertEquals(15, mmHeap.size());
assertTrue("Heap is not intact initially", mmHeap.isIntact());
mmHeap.remove(12);
assertEquals(14, mmHeap.size());
assertTrue("Heap is not intact after remove()", mmHeap.isIntact());
}
代码示例来源:origin: com.google.guava/guava-tests
public void testRemove() {
MinMaxPriorityQueue<Integer> mmHeap = MinMaxPriorityQueue.create();
mmHeap.addAll(Lists.newArrayList(1, 2, 3, 4, 47, 1, 5, 3, 0));
assertTrue("Heap is not intact initally", mmHeap.isIntact());
assertEquals(9, mmHeap.size());
mmHeap.remove(5);
assertEquals(8, mmHeap.size());
assertTrue("Heap is not intact after remove()", mmHeap.isIntact());
assertEquals(47, (int) mmHeap.pollLast());
assertEquals(4, (int) mmHeap.pollLast());
mmHeap.removeAll(Lists.newArrayList(2, 3));
assertEquals(3, mmHeap.size());
assertTrue("Heap is not intact after removeAll()", mmHeap.isIntact());
}
内容来源于网络,如有侵权,请联系作者删除!