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

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

Description

unpackw

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
/**/*from  w w  w .  j a  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 unpackw(int[] sourcearray, int arraypos, int[] data, int num, int b) {
        int howmanyfit = 32 / b;
        if (num > howmanyfit) {
            System.arraycopy(sourcearray, arraypos, data, 0, num);
            return num + arraypos;
        }
        final int mask = (1 << b) - 1;
        int val = sourcearray[arraypos];
        for (int k = 0; k < num; ++k) {
            data[k] = (val & mask);
            val >>>= b;
        }
        return arraypos + 1;
    }
}

Related

  1. unpackIntegerByWidth(int len, byte[] buf, int offset)
  2. unpackLE(long aValue, byte[] aBuf, int aOffset)
  3. UnpackLittle32(byte[] bytes, int integer)
  4. unpackLittleEndianLong(byte[] bytes)
  5. unpackLong(byte[] arr, int i, int j)