Java Array Unpack unpack(int[] sourcearray, int arraypos, int[] data, int datapos, int num, int b)

Here you can find the source of unpack(int[] sourcearray, int arraypos, int[] data, int datapos, int num, int b)

Description

unpack

License

Open Source License

Declaration

protected static int unpack(int[] sourcearray, int arraypos, int[] data, int datapos, int num, int b) 

Method Source Code

//package com.java2s;
/**//from w  w w. ja v  a  2 s  .c o m
 * This code is released under the
 * Apache License Version 2.0 http://www.apache.org/licenses/.
 *
 * (c) Daniel Lemire, http://lemire.me/en/
 */

public class Main {
    protected static int unpack(int[] sourcearray, int arraypos, int[] data, int datapos, int num, int b) {
        if (b > 16) {
            System.arraycopy(sourcearray, arraypos, data, 0, num);
            return num + arraypos;
        }
        final int mask = (1 << b) - 1;
        int inwordpointer = 0;
        for (int k = 0; k < num; ++k) {
            data[k + datapos] = ((sourcearray[arraypos] >>> inwordpointer) & mask);
            inwordpointer += b;
            final int increment = ((inwordpointer + b - 1) >> 5);
            arraypos += increment;
            inwordpointer &= ~(-increment);
        }
        return arraypos + (inwordpointer > 0 ? 1 : 0);
    }
}

Related

  1. unpack(byte[] array)
  2. unpack(byte[] bytes)
  3. unpack(double[] packed, int width, int height, int outputIndex)
  4. unpackBCD(byte[] source)
  5. unpackDie(byte[] bytes)
  6. UnpackFloat(byte[] bytes, float value)
  7. UnpackFloatBuffer(byte[] buffer, long bytes_read, long num_loaded, float[] list)