Example usage for io.netty.util.internal MathUtil findNextPositivePowerOfTwo

List of usage examples for io.netty.util.internal MathUtil findNextPositivePowerOfTwo

Introduction

In this page you can find the example usage for io.netty.util.internal MathUtil findNextPositivePowerOfTwo.

Prototype

public static int findNextPositivePowerOfTwo(final int value) 

Source Link

Document

Fast method of finding the next power of 2 greater than or equal to the supplied value.

Usage

From source file:com.yahoo.pulsar.common.util.collections.GrowableArrayBlockingQueue.java

License:Apache License

@SuppressWarnings("unchecked")
public GrowableArrayBlockingQueue(int initialCapacity) {
    headIndex.value = 0;/*from  w ww .j  av a  2 s.c  o m*/
    tailIndex.value = 0;

    int capacity = MathUtil.findNextPositivePowerOfTwo(initialCapacity);
    data = (T[]) new Object[capacity];
}

From source file:org.apache.activemq.artemis.utils.AbstractByteBufPool.java

License:Apache License

public AbstractByteBufPool(final int capacity) {
    entries = (T[]) new Object[MathUtil.findNextPositivePowerOfTwo(capacity)];
    mask = entries.length - 1;//w w  w.ja  v a 2 s . c o  m
    //log2 of entries.length
    shift = 31 - Integer.numberOfLeadingZeros(entries.length);
}

From source file:org.apache.activemq.artemis.utils.AbstractPool.java

License:Apache License

public AbstractPool(final int capacity) {
    entries = (O[]) new Object[MathUtil.findNextPositivePowerOfTwo(capacity)];
    mask = entries.length - 1;/*from   w ww . j  a v  a 2 s  . c  o m*/
    //log2 of entries.length
    shift = 31 - Integer.numberOfLeadingZeros(entries.length);
}

From source file:org.apache.pulsar.common.util.collections.GrowablePriorityLongPairQueue.java

License:Apache License

public GrowablePriorityLongPairQueue(int initialCapacity) {
    checkArgument(initialCapacity > 0);
    this.capacity = MathUtil.findNextPositivePowerOfTwo(initialCapacity);
    data = new long[2 * capacity];
    Arrays.fill(data, 0, data.length, EmptyItem);
}