當前位置: 首頁>>代碼示例>>Java>>正文


Java IntMath.pow方法代碼示例

本文整理匯總了Java中com.google.common.math.IntMath.pow方法的典型用法代碼示例。如果您正苦於以下問題:Java IntMath.pow方法的具體用法?Java IntMath.pow怎麽用?Java IntMath.pow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.math.IntMath的用法示例。


在下文中一共展示了IntMath.pow方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: OoaBFilter

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * Constructs a OoaBFilter with an underlying array of the given size, rounded up to the next
 * power of two.
 *
 * This rounding occurs because the hashing is much faster on an array the size of a power of two.
 *
 * @param size The size of the underlying array.
 * @param bufSize The size of the buffers occupying each slot in the array.
 */
public OoaBFilter(int size, int bufSize) {
  if (size <= 0) {
    throw new IllegalArgumentException("array size must be greater than zero, was " + size);
  }
  if (size > MAX_SIZE) {
    throw new IllegalArgumentException(
        "array size may not be larger than 2**31-1, but will be rounded to larger. was " + size);
  }
  // round to the next largest power of two
  int poweredSize = IntMath.pow(2, IntMath.log2(size, RoundingMode.CEILING));
  this.sizeMask = poweredSize - 1;
  this.array = new ByteBuffer[poweredSize];

  // pre-allocate a ByteBuffer for each slot in the array
  int i = 0;
  while (i < poweredSize) {
    array[i] = ByteBuffer.allocate(bufSize);
    i++;
  }
}
 
開發者ID:automenta,項目名稱:spimedb,代碼行數:30,代碼來源:OoaBFilter.java

示例2: allGetterFlagsAreAccepted

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Test
public void allGetterFlagsAreAccepted() {
    final RequestLogAvailability[] values = RequestLogAvailability.values();
    final int end = IntMath.pow(2, values.length);
    for (int i = 0; i < end; i++) {
        int flags = 0;
        for (RequestLogAvailability v : values) {
            if ((i & 1 << v.ordinal()) != 0) {
                flags |= v.getterFlags();
            }
        }

        if (flags != 0) {
            assertThat(RequestLogAvailabilitySet.of(flags)).isNotEmpty();
        }
    }
}
 
開發者ID:line,項目名稱:armeria,代碼行數:18,代碼來源:RequestLogAvailabilitySetTest.java

示例3: testCounts

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Test
public void testCounts() {
	String ascii = "abcdefghijklmnopqrstuvwxyz";
	String range = ascii.toLowerCase() + ascii.toUpperCase();
	int rangeA = IntMath.pow(range.length(), 1);
	assertEquals(rangeA, Iterables.size(new Mutator(range, 1, 1).mutate()));

	int rangeB = IntMath.pow(range.length(), 2) + rangeA;
	assertEquals(rangeB, Iterables.size(new Mutator(range, 1, 2).mutate()));

	int rangeC = IntMath.pow(range.length(), 3) + rangeB;
	assertEquals(rangeC, Iterables.size(new Mutator(range, 1, 3).mutate()));

	int rangeD = IntMath.pow(range.length(), 4) + rangeC;
	assertEquals(rangeD, Iterables.size(new Mutator(range, 1, 4).mutate()));
}
 
開發者ID:pfichtner,項目名稱:jcrunch,代碼行數:17,代碼來源:TestMutater.java

示例4: getInteger

import com.google.common.math.IntMath; //導入方法依賴的package包/類
protected static int getInteger(byte[] b) {
    int sum = 0;
    for (int i = 0; i < b.length; i++) {
        final int reverseIndex = b.length - 1 - i;
        final int factor = IntMath.pow(256, reverseIndex);
        final int base = UnsignedBytes.toInt(b[i]);
        sum += base * factor;
    }
    return sum;
}
 
開發者ID:kaspersorensen,項目名稱:kafka-record-updater,代碼行數:11,代碼來源:SegmentFileUpdater.java

示例5: UnBloomFilter

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * Constructs a OoaBFilter with an underlying array of the given size, rounded up to the next
 * power of two.
 * <p>
 * This rounding occurs because the hashing is much faster on an array the size of a power of two.
 *
 * @param size    The size of the underlying array.
 * @param asBytes
 */
public UnBloomFilter(int size, Function<X, byte[]> asBytes) {
    final int MAX_SIZE = 1 << 30;
    if (size <= 0 || size > MAX_SIZE) {
        throw new IllegalArgumentException(
                "array size must be greater than 0 and array size may not be larger than 2**31-1, but will be rounded to larger. was " + size);
    }

    this.asBytes = asBytes;
    int poweredSize = IntMath.pow(2, IntMath.log2(size, RoundingMode.CEILING)); // round to the next largest power of two
    this.array = new AtomicReferenceArray(poweredSize);
    this.sizeMask = poweredSize - 1;

}
 
開發者ID:automenta,項目名稱:spimedb,代碼行數:23,代碼來源:UnBloomFilter.java

示例6: ByteArrayFilter

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * Constructs a ByteArrayFilter with an underlying array of the given size, rounded up to the next
 * power of two.
 *
 * This rounding occurs because the hashing is much faster on an array the size of a power of two.
 * If you really want a different sized array, used the AtomicReferenceArray constructor.
 *
 * @param size The size of the underlying array.
 */
public ByteArrayFilter(int size) {
  if (size <= 0) {
    throw new IllegalArgumentException("array size must be greater than zero, was " + size);
  }
  if (size > MAX_SIZE) {
    throw new IllegalArgumentException(
        "array size may not be larger than 2**31-1, but will be rounded to larger. was " + size);
  }
  // round to the next largest power of two
  int poweredSize = IntMath.pow(2, IntMath.log2(size, RoundingMode.CEILING));
  this.sizeMask = poweredSize - 1;
  this.array = new AtomicReferenceArray<>(poweredSize);
}
 
開發者ID:automenta,項目名稱:spimedb,代碼行數:23,代碼來源:ByteArrayFilter.java

示例7: pow

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Benchmark int pow(int reps) {
  int tmp = 0;
  for (int i = 0; i < reps; i++) {
    int j = i & ARRAY_MASK;
    tmp += IntMath.pow(positive[j], exponent[j]);
  }
  return tmp;
}
 
開發者ID:sander120786,項目名稱:guava-libraries,代碼行數:9,代碼來源:IntMathBenchmark.java

示例8: getBooleanFunctionParamsMap

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * Returns a map that maps each boolean function to the parameters for the function.
 */
public static Map<Integer, int[]> getBooleanFunctionParamsMap(int inputCount, int paramCount,
    ParameterizedBooleanFunction booleanFunction) {
  Map<Integer, int[]> booleanFunctionParamsMap = new TreeMap<>();
  for (int cnt = 0; cnt < IntMath.pow(2, paramCount); cnt++) {
    int[] params = getBitsAsIntArray(cnt);
    int function = getBooleanFunctionValues(inputCount, booleanFunction, params);
    booleanFunctionParamsMap.put(function, params);
  }
  return booleanFunctionParamsMap;
}
 
開發者ID:thorntonv,項目名稱:mechaverse,代碼行數:14,代碼來源:BooleanFunctions.java

示例9: getBooleanFunctionValues

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * Returns the integer that uniquely represents the boolean function specified by the given
 * parameters.
 */
public static int getBooleanFunctionValues(int inputCount,
    ParameterizedBooleanFunction booleanFunction, int[] params) {
  int value = 0;
  for (int inputValue = 0; inputValue < IntMath.pow(2, inputCount); inputValue++) {
    value <<= 1;
    value |= booleanFunction.getValue(getBitsAsIntArray(inputValue), params);
  }
  return value;
}
 
開發者ID:thorntonv,項目名稱:mechaverse,代碼行數:14,代碼來源:BooleanFunctions.java

示例10: OoaBFilter

import com.google.common.math.IntMath; //導入方法依賴的package包/類
public OoaBFilter(int size) {
    leastSignificantBitsArray = new long[size];
    mostSignificantBitsArray = new long[size];

    this.sizeMask = IntMath.pow(2, IntMath.log2(size, RoundingMode.CEILING)) - 1;
}
 
開發者ID:rakam-io,項目名稱:rakam,代碼行數:7,代碼來源:OoaBFilter.java

示例11: hashCode

import com.google.common.math.IntMath; //導入方法依賴的package包/類
@Override public int hashCode() {
    return getLeft().hashCode() + (IntMath.pow(31, getLeft().size()) * getRight().hashCode());
}
 
開發者ID:metaborg,項目名稱:nabl,代碼行數:4,代碼來源:ComposedScopePath.java

示例12: pow

import com.google.common.math.IntMath; //導入方法依賴的package包/類
/**
 * 平方
 * 
 * @param k
 *            平方次數,不能為負數, k=0時返回1.
 */
public static int pow(int b, int k) {
	return IntMath.pow(b, k);
}
 
開發者ID:zhangjunfang,項目名稱:util,代碼行數:10,代碼來源:MathUtil.java


注:本文中的com.google.common.math.IntMath.pow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。