getPowerOf2() public static method

public static getPowerOf2 ( int n ) : int
n int
return int
Beispiel #1
0
 public BytesWriteStream(int size)
 {
     _buf      = new byte[MathUtils.getPowerOf2(size)];
     _length   = 0;
     _position = 0;
     _canGrow  = true;
 }
Beispiel #2
0
        protected int countCapacity(int capacity)
        {
            capacity = MathUtils.getPowerOf2(capacity);

            if (capacity < _minSize)
            {
                capacity = _minSize;
            }

            return(capacity);
        }
        private void grow(int len)
        {
            int cap = MathUtils.getPowerOf2(len);

            if (cap > _buf.Length)
            {
                byte[] bs = new byte[cap];

                Buffer.BlockCopy(_buf, 0, bs, 0, _buf.Length);

                _buf = bs;
            }
        }