本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.orderedBy()
方法的一些代码示例,展示了MinMaxPriorityQueue.orderedBy()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.orderedBy()
方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:orderedBy
[英]Creates and returns a new builder, configured to build MinMaxPriorityQueue instances that use comparator to determine the least and greatest elements.
[中]创建并返回一个新的生成器,配置为生成MinMaxPriorityQueue实例,该实例使用comparator来确定最小和最大元素。
代码示例来源:origin: apache/incubator-druid
public ScalingStats(int capacity)
{
if (capacity == 0) {
this.recentEvents = MinMaxPriorityQueue.orderedBy(COMPARATOR).create();
} else {
this.recentEvents = MinMaxPriorityQueue
.orderedBy(COMPARATOR)
.maximumSize(capacity)
.create();
}
}
代码示例来源:origin: apache/incubator-druid
@Override
protected Queue<EventHolder> instantiatePQueue()
{
int threshold = pagingSpec.getThreshold();
return MinMaxPriorityQueue.orderedBy(descending ? comparator.reversed() : comparator)
.maximumSize(threshold > 0 ? threshold : Integer.MAX_VALUE)
.create();
}
代码示例来源:origin: apache/incubator-druid
.orderedBy(ordering)
.maximumSize(limit)
.create();
代码示例来源:origin: apache/incubator-pinot
MinMaxPriorityQueue.orderedBy(comparator).maximumSize(completedServers.size()).create();
completedServersQueue.addAll(completedServerToNumSegments.entrySet());
代码示例来源:origin: apache/incubator-pinot
MinMaxPriorityQueue.orderedBy(comparator).maximumSize(MAX_CHILDREN).create();
StarTreeJsonNode allNode = null;
代码示例来源:origin: apache/ignite
TopNWordsReducer() {
q = orderedBy(reverseOrder(new Comparator<Entry<Integer, String>>() {
@Override public int compare(Entry<Integer, String> o1, Entry<Integer, String> o2) {
return o1.getKey().compareTo(o2.getKey());
}
})).expectedSize(POPULAR_WORDS_CNT).maximumSize(POPULAR_WORDS_CNT).create();
}
代码示例来源: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/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: google/guava
public void testCreation_comparator() {
MinMaxPriorityQueue<Integer> queue = MinMaxPriorityQueue.orderedBy(SOME_COMPARATOR).create();
assertEquals(11, queue.capacity());
checkUnbounded(queue);
assertSame(SOME_COMPARATOR, queue.comparator());
}
代码示例来源:origin: apache/incubator-gobblin
int estimatedMultiWorkUnits = Math.min(estimateByWeight, workUnits.size());
MinMaxPriorityQueue<MultiWorkUnit> pQueue = MinMaxPriorityQueue.orderedBy(new MultiWorkUnitComparator()).create();
for (int i = 0; i < estimatedMultiWorkUnits; i++) {
pQueue.add(MultiWorkUnit.createEmpty());
代码示例来源:origin: apache/incubator-gobblin
MinMaxPriorityQueue.orderedBy(LOAD_ASC_COMPARATOR).expectedSize(numOfMultiWorkUnits).create();
for (int i = 0; i < numOfMultiWorkUnits; i++) {
MultiWorkUnit multiWorkUnit = MultiWorkUnit.createEmpty();
代码示例来源:origin: google/guava
public void testCreation_expectedSize_comparator() {
MinMaxPriorityQueue<Integer> queue =
MinMaxPriorityQueue.orderedBy(SOME_COMPARATOR).expectedSize(8).create();
assertEquals(8, queue.capacity());
checkUnbounded(queue);
assertSame(SOME_COMPARATOR, queue.comparator());
}
代码示例来源:origin: google/guava
public void testCreation_comparator_maximumSize() {
MinMaxPriorityQueue<Integer> queue =
MinMaxPriorityQueue.orderedBy(SOME_COMPARATOR).maximumSize(42).create();
assertEquals(11, queue.capacity());
assertEquals(42, queue.maximumSize);
assertSame(SOME_COMPARATOR, queue.comparator());
}
代码示例来源:origin: google/guava
public void testCreation_comparator_withContents() {
MinMaxPriorityQueue<Integer> queue =
MinMaxPriorityQueue.orderedBy(SOME_COMPARATOR).create(NUMBERS);
assertEquals(6, queue.size());
assertEquals(11, queue.capacity());
checkUnbounded(queue);
assertSame(SOME_COMPARATOR, queue.comparator());
}
代码示例来源:origin: google/guava
public void testCreation_allOptions() {
MinMaxPriorityQueue<Integer> queue =
MinMaxPriorityQueue.orderedBy(SOME_COMPARATOR)
.expectedSize(8)
.maximumSize(42)
.create(NUMBERS);
assertEquals(6, queue.size());
assertEquals(8, queue.capacity());
assertEquals(42, queue.maximumSize);
assertSame(SOME_COMPARATOR, queue.comparator());
}
代码示例来源:origin: apache/phoenix
public MappedByteBufferResultEntryPriorityQueue(int index,
int thresholdBytes, int limit, Comparator<ResultEntry> comparator) {
super(index, thresholdBytes, limit >= 0);
this.results = limit < 0 ?
MinMaxPriorityQueue.<ResultEntry> orderedBy(comparator).create()
: MinMaxPriorityQueue.<ResultEntry> orderedBy(comparator).maximumSize(limit).create();
}
代码示例来源:origin: forcedotcom/phoenix
public MappedByteBufferPriorityQueue(int index, int limit, int thresholdBytes,
Comparator<ResultEntry> comparator) throws IOException {
this.index = index;
this.limit = limit;
this.thresholdBytes = thresholdBytes;
results = limit < 0 ?
MinMaxPriorityQueue.<ResultEntry> orderedBy(comparator).create()
: MinMaxPriorityQueue.<ResultEntry> orderedBy(comparator).maximumSize(limit).create();
}
代码示例来源:origin: forcedotcom/phoenix
@Override
public ResultEntry peek() {
if (mergedQueue == null) {
mergedQueue = MinMaxPriorityQueue.<ResultEntry> orderedBy(
comparator).maximumSize(queues.size()).create();
for (MappedByteBufferPriorityQueue queue : queues) {
try {
IndexedResultEntry next = queue.getNextResult();
if (next != null) {
mergedQueue.add(next);
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}
if (!mergedQueue.isEmpty()) {
IndexedResultEntry re = mergedQueue.peekFirst();
if (re != null) {
return re;
}
}
return null;
}
代码示例来源:origin: apache/phoenix
private void initMergedQueue() {
if (mergedQueue == null && currentIndex >= 0) {
mergedQueue = MinMaxPriorityQueue.<MappedByteBufferSegmentQueue<T>> orderedBy(
getSegmentQueueComparator()).maximumSize(currentIndex + 1).create();
for (MappedByteBufferSegmentQueue<T> queue : getSegmentQueues()) {
T re = queue.peek();
if (re != null) {
mergedQueue.add(queue);
}
}
}
}
代码示例来源:origin: forcedotcom/phoenix
@Override
public ResultEntry poll() {
if (mergedQueue == null) {
mergedQueue = MinMaxPriorityQueue.<ResultEntry> orderedBy(
comparator).maximumSize(queues.size()).create();
for (MappedByteBufferPriorityQueue queue : queues) {
内容来源于网络,如有侵权,请联系作者删除!