本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.heapForIndex()
方法的一些代码示例,展示了MinMaxPriorityQueue.heapForIndex()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.heapForIndex()
方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:heapForIndex
暂无
代码示例来源:origin: google/guava
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used in testing.
*
* <p>TODO(kevinb): move to the test class?
*/
@VisibleForTesting
boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: google/j2objc
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used in testing.
*
* <p>TODO(kevinb): move to the test class?
*/
@VisibleForTesting
boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: wildfly/wildfly
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used in testing.
*
* <p>TODO(kevinb): move to the test class?
*/
@VisibleForTesting
boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: google/guava
/**
* Adds the given element to this queue. If this queue has a maximum size, after adding {@code
* element} the queue will automatically evict its greatest element (according to its comparator),
* which may be {@code element} itself.
*/
@CanIgnoreReturnValue
@Override
public boolean offer(E element) {
checkNotNull(element);
modCount++;
int insertIndex = size++;
growIfNeeded();
// Adds the element to the end of the heap and bubbles it up to the correct
// position.
heapForIndex(insertIndex).bubbleUp(insertIndex, element);
return size <= maximumSize || pollLast() != element;
}
代码示例来源:origin: google/j2objc
/**
* Adds the given element to this queue. If this queue has a maximum size, after adding {@code
* element} the queue will automatically evict its greatest element (according to its comparator),
* which may be {@code element} itself.
*/
@CanIgnoreReturnValue
@Override
public boolean offer(E element) {
checkNotNull(element);
modCount++;
int insertIndex = size++;
growIfNeeded();
// Adds the element to the end of the heap and bubbles it up to the correct
// position.
heapForIndex(insertIndex).bubbleUp(insertIndex, element);
return size <= maximumSize || pollLast() != element;
}
代码示例来源:origin: google/guava
private MoveDesc<E> fillHole(int index, E toTrickle) {
Heap heap = heapForIndex(index);
// We consider elementData(index) a "hole", and we want to fill it
// with the last element of the heap, toTrickle.
// Since the last element of the heap is from the bottom level, we
// optimistically fill index position with elements from lower levels,
// moving the hole down. In most cases this reduces the number of
// comparisons with toTrickle, but in some cases we will need to bubble it
// all the way up again.
int vacated = heap.fillHoleAt(index);
// Try to see if toTrickle can be bubbled up min levels.
int bubbledTo = heap.bubbleUpAlternatingLevels(vacated, toTrickle);
if (bubbledTo == vacated) {
// Could not bubble toTrickle up min levels, try moving
// it from min level to max level (or max to min level) and bubble up
// there.
return heap.tryCrossOverAndBubbleUp(index, vacated, toTrickle);
} else {
return (bubbledTo < index) ? new MoveDesc<E>(toTrickle, elementData(index)) : null;
}
}
代码示例来源:origin: wildfly/wildfly
/**
* Adds the given element to this queue. If this queue has a maximum size, after adding {@code
* element} the queue will automatically evict its greatest element (according to its comparator),
* which may be {@code element} itself.
*/
@CanIgnoreReturnValue
@Override
public boolean offer(E element) {
checkNotNull(element);
modCount++;
int insertIndex = size++;
growIfNeeded();
// Adds the element to the end of the heap and bubbles it up to the correct
// position.
heapForIndex(insertIndex).bubbleUp(insertIndex, element);
return size <= maximumSize || pollLast() != element;
}
代码示例来源:origin: google/j2objc
private MoveDesc<E> fillHole(int index, E toTrickle) {
Heap heap = heapForIndex(index);
// We consider elementData(index) a "hole", and we want to fill it
// with the last element of the heap, toTrickle.
// Since the last element of the heap is from the bottom level, we
// optimistically fill index position with elements from lower levels,
// moving the hole down. In most cases this reduces the number of
// comparisons with toTrickle, but in some cases we will need to bubble it
// all the way up again.
int vacated = heap.fillHoleAt(index);
// Try to see if toTrickle can be bubbled up min levels.
int bubbledTo = heap.bubbleUpAlternatingLevels(vacated, toTrickle);
if (bubbledTo == vacated) {
// Could not bubble toTrickle up min levels, try moving
// it from min level to max level (or max to min level) and bubble up
// there.
return heap.tryCrossOverAndBubbleUp(index, vacated, toTrickle);
} else {
return (bubbledTo < index) ? new MoveDesc<E>(toTrickle, elementData(index)) : null;
}
}
代码示例来源:origin: google/guava
int lastElementAt = heapForIndex(size).swapWithConceptuallyLastElement(actualLastElement);
if (lastElementAt == index) {
代码示例来源:origin: wildfly/wildfly
private MoveDesc<E> fillHole(int index, E toTrickle) {
Heap heap = heapForIndex(index);
// We consider elementData(index) a "hole", and we want to fill it
// with the last element of the heap, toTrickle.
// Since the last element of the heap is from the bottom level, we
// optimistically fill index position with elements from lower levels,
// moving the hole down. In most cases this reduces the number of
// comparisons with toTrickle, but in some cases we will need to bubble it
// all the way up again.
int vacated = heap.fillHoleAt(index);
// Try to see if toTrickle can be bubbled up min levels.
int bubbledTo = heap.bubbleUpAlternatingLevels(vacated, toTrickle);
if (bubbledTo == vacated) {
// Could not bubble toTrickle up min levels, try moving
// it from min level to max level (or max to min level) and bubble up
// there.
return heap.tryCrossOverAndBubbleUp(index, vacated, toTrickle);
} else {
return (bubbledTo < index) ? new MoveDesc<E>(toTrickle, elementData(index)) : null;
}
}
代码示例来源:origin: google/j2objc
int lastElementAt = heapForIndex(size).swapWithConceptuallyLastElement(actualLastElement);
if (lastElementAt == index) {
代码示例来源:origin: wildfly/wildfly
int lastElementAt = heapForIndex(size).swapWithConceptuallyLastElement(actualLastElement);
if (lastElementAt == index) {
代码示例来源:origin: com.atlassian.bundles/guava
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used
* in testing.
*
* TODO(kevinb): move to the test class?
*/
@VisibleForTesting boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.google.guava/guava-jdk5
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used
* in testing.
*
* TODO(kevinb): move to the test class?
*/
@VisibleForTesting boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: org.sonatype.sisu/sisu-guava
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used
* in testing.
*
* TODO(kevinb): move to the test class?
*/
@VisibleForTesting boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used
* in testing.
*
* TODO(kevinb): move to the test class?
*/
@VisibleForTesting boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: Nextdoor/bender
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used
* in testing.
*
* TODO(kevinb): move to the test class?
*/
@VisibleForTesting boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used
* in testing.
*
* TODO(kevinb): move to the test class?
*/
@VisibleForTesting boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used in testing.
*
* <p>TODO(kevinb): move to the test class?
*/
@VisibleForTesting
boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
/**
* Returns {@code true} if the MinMax heap structure holds. This is only used
* in testing.
*
* TODO(kevinb): move to the test class?
*/
@VisibleForTesting boolean isIntact() {
for (int i = 1; i < size; i++) {
if (!heapForIndex(i).verifyIndex(i)) {
return false;
}
}
return true;
}
内容来源于网络,如有侵权,请联系作者删除!