com.google.common.collect.MinMaxPriorityQueue.capAtMaximumSize()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.8k)|赞(0)|评价(0)|浏览(81)

本文整理了Java中com.google.common.collect.MinMaxPriorityQueue.capAtMaximumSize()方法的一些代码示例,展示了MinMaxPriorityQueue.capAtMaximumSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MinMaxPriorityQueue.capAtMaximumSize()方法的具体详情如下:
包路径:com.google.common.collect.MinMaxPriorityQueue
类名称:MinMaxPriorityQueue
方法名:capAtMaximumSize

MinMaxPriorityQueue.capAtMaximumSize介绍

[英]There's no reason for the queueSize to ever be more than maxSize + 1
[中]queueSize没有理由超过maxSize+1

代码示例

代码示例来源:origin: google/guava

@VisibleForTesting
static int initialQueueSize(
  int configuredExpectedSize, int maximumSize, Iterable<?> initialContents) {
 // Start with what they said, if they said it, otherwise DEFAULT_CAPACITY
 int result =
   (configuredExpectedSize == Builder.UNSET_EXPECTED_SIZE)
     ? DEFAULT_CAPACITY
     : configuredExpectedSize;
 // Enlarge to contain initial contents
 if (initialContents instanceof Collection) {
  int initialSize = ((Collection<?>) initialContents).size();
  result = Math.max(result, initialSize);
 }
 // Now cap it at maxSize + 1
 return capAtMaximumSize(result, maximumSize);
}

代码示例来源:origin: google/guava

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity =
   (oldCapacity < 64) ? (oldCapacity + 1) * 2 : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: google/j2objc

@VisibleForTesting
static int initialQueueSize(
  int configuredExpectedSize, int maximumSize, Iterable<?> initialContents) {
 // Start with what they said, if they said it, otherwise DEFAULT_CAPACITY
 int result =
   (configuredExpectedSize == Builder.UNSET_EXPECTED_SIZE)
     ? DEFAULT_CAPACITY
     : configuredExpectedSize;
 // Enlarge to contain initial contents
 if (initialContents instanceof Collection) {
  int initialSize = ((Collection<?>) initialContents).size();
  result = Math.max(result, initialSize);
 }
 // Now cap it at maxSize + 1
 return capAtMaximumSize(result, maximumSize);
}

代码示例来源:origin: google/j2objc

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity =
   (oldCapacity < 64) ? (oldCapacity + 1) * 2 : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: wildfly/wildfly

@VisibleForTesting
static int initialQueueSize(
  int configuredExpectedSize, int maximumSize, Iterable<?> initialContents) {
 // Start with what they said, if they said it, otherwise DEFAULT_CAPACITY
 int result =
   (configuredExpectedSize == Builder.UNSET_EXPECTED_SIZE)
     ? DEFAULT_CAPACITY
     : configuredExpectedSize;
 // Enlarge to contain initial contents
 if (initialContents instanceof Collection) {
  int initialSize = ((Collection<?>) initialContents).size();
  result = Math.max(result, initialSize);
 }
 // Now cap it at maxSize + 1
 return capAtMaximumSize(result, maximumSize);
}

代码示例来源:origin: wildfly/wildfly

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity =
   (oldCapacity < 64) ? (oldCapacity + 1) * 2 : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: com.atlassian.bundles/guava

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : (oldCapacity / 2) * 3;
 if (newCapacity < 0) {
  newCapacity = Integer.MAX_VALUE; // overflow - hotspot will throw OOME
 }
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: com.google.guava/guava-jdk5

@VisibleForTesting static int initialQueueSize(int configuredExpectedSize,
  int maximumSize, Iterable<?> initialContents) {
 // Start with what they said, if they said it, otherwise DEFAULT_CAPACITY
 int result = (configuredExpectedSize == Builder.UNSET_EXPECTED_SIZE)
   ? DEFAULT_CAPACITY
   : configuredExpectedSize;
 // Enlarge to contain initial contents
 if (initialContents instanceof Collection) {
  int initialSize = ((Collection<?>) initialContents).size();
  result = Math.max(result, initialSize);
 }
 // Now cap it at maxSize + 1
 return capAtMaximumSize(result, maximumSize);
}

代码示例来源:origin: com.atlassian.bundles/guava

@VisibleForTesting static int initialQueueSize(int configuredExpectedSize,
  int maximumSize, Iterable<?> initialContents) {
 // Start with what they said, if they said it, otherwise DEFAULT_CAPACITY
 int result = (configuredExpectedSize == Builder.UNSET_EXPECTED_SIZE)
   ? DEFAULT_CAPACITY
   : configuredExpectedSize;
 // Enlarge to contain initial contents
 if (initialContents instanceof Collection) {
  int initialSize = ((Collection<?>) initialContents).size();
  result = Math.max(result, initialSize);
 }
 // Now cap it at maxSize + 1
 return capAtMaximumSize(result, maximumSize);
}

代码示例来源:origin: com.google.guava/guava-jdk5

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: org.kill-bill.billing/killbill-platform-osgi-bundles-logger

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity =
   (oldCapacity < 64) ? (oldCapacity + 1) * 2 : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: com.diffplug.guava/guava-collect

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
  int oldCapacity = queue.length;
  int newCapacity = (oldCapacity < 64)
      ? (oldCapacity + 1) * 2
      : IntMath.checkedMultiply(oldCapacity / 2, 3);
  return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: org.jboss.eap/wildfly-client-all

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity =
   (oldCapacity < 64) ? (oldCapacity + 1) * 2 : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: org.sonatype.sisu/sisu-guava

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: at.bestsolution.efxclipse.eclipse/com.google.guava

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: org.hudsonci.lib.guava/guava

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

代码示例来源:origin: Nextdoor/bender

/** Returns ~2x the old capacity if small; ~1.5x otherwise. */
private int calculateNewCapacity() {
 int oldCapacity = queue.length;
 int newCapacity = (oldCapacity < 64)
   ? (oldCapacity + 1) * 2
   : IntMath.checkedMultiply(oldCapacity / 2, 3);
 return capAtMaximumSize(newCapacity, maximumSize);
}

相关文章