Log2() public static method

Calculate the log base 2 of the supplied integer, essentially reports the location of the highest bit.
public static Log2 ( int i ) : int
i int Value to calculate log2 for.
return int
Exemplo n.º 1
0
 public MultiProducerSequencer(int bufferSize, IWaitStrategy waitStrategy)
     : base(bufferSize, waitStrategy)
 {
     _availableBuffer = new int[bufferSize];
     _indexMask       = bufferSize - 1;
     _indexShift      = Util.Log2(bufferSize);
     InitialiseAvailableBuffer();
 }
 public MultiProducerSequencer(int bufferSize, IWaitStrategy waitStrategy)
     : base(bufferSize, waitStrategy)
 {
     indexMask          = bufferSize - 1;
     indexShift         = Util.Log2(bufferSize);
     pendingPublication = new _Volatile.IntegerArray(bufferSize);
     _pendingMask       = bufferSize - 1;
     InitialiseAvailableBuffer();
 }
Exemplo n.º 3
0
        public MultiProducerSequencer(int bufferSize, IWaitStrategy waitStrategy)
        {
            if (bufferSize < 1)
            {
                throw new ArgumentException("bufferSize must not be less than 1");
            }
            if (!bufferSize.IsPowerOf2())
            {
                throw new ArgumentException("bufferSize must be a power of 2");
            }

            _bufferSize             = bufferSize;
            _waitStrategy           = waitStrategy;
            _isBlockingWaitStrategy = !(waitStrategy is INonBlockingWaitStrategy);
            _availableBuffer        = new int[bufferSize];
            _indexMask  = bufferSize - 1;
            _indexShift = Util.Log2(bufferSize);

            InitialiseAvailableBuffer();
        }