@Test public void testDecompress1() { byte[] bytes = Base64.getDecoder().decode(data1); List<Integer> ls = riceCompression.decompress(parameter, bytes); Assert.assertEquals(336, ls.size()); }
public List<Integer> decompress(int riceParameter, byte[] data) { BitSet bits = new BitSet(data.length * 8); for (int i = 0; i < data.length; i++) { BitSet bitsOfByte = BitSet.valueOf(makeArrayOfByte(data[i])); for (int j = 0; j < bitsOfByte.size(); j++) { bits.set(i * BYTE_BITS_SIZE + j, bitsOfByte.get(j)); } } List<Integer> result = new LinkedList<>(); for (int n = 0; n < bits.size();) { int quotient = 0; while (bits.get(n++)) { quotient++; } int remainder = 0; BitSet range = bits.get(n, n + riceParameter); for (int i = 0; i < range.size(); i++) { if (range.get(i)) { remainder += (1 << range.size() - i - 1); } } n += riceParameter; int value = (quotient << riceParameter) + remainder; result.add(value); } for (int i = result.size() - 1; i >= 0; --i) { if (result.get(i) == 0) { result.remove(i); } } return result; }
RiceCompression { public List<Integer> decompress(int riceParameter, byte[] data) { BitSet bits = new BitSet(data.length * 8); for (int i = 0; i < data.length; i++) { BitSet bitsOfByte = BitSet.valueOf(makeArrayOfByte(data[i])); for (int j = 0; j < bitsOfByte.size(); j++) { bits.set(i * BYTE_BITS_SIZE + j, bitsOfByte.get(j)); } } List<Integer> result = new LinkedList<>(); for (int n = 0; n < bits.size();) { int quotient = 0; while (bits.get(n++)) { quotient++; } int remainder = 0; BitSet range = bits.get(n, n + riceParameter); for (int i = 0; i < range.size(); i++) { if (range.get(i)) { remainder += (1 << range.size() - i - 1); } } n += riceParameter; int value = (quotient << riceParameter) + remainder; result.add(value); } for (int i = result.size() - 1; i >= 0; --i) { if (result.get(i) == 0) { result.remove(i); } } return result; } }
RiceCompression { public List<Integer> decompress(int riceParameter, byte[] data) { BitSet bits = new BitSet(data.length * 8); for (int i = 0; i < data.length; i++) { BitSet bitsOfByte = BitSet.valueOf(makeArrayOfByte(data[i])); for (int j = 0; j < bitsOfByte.size(); j++) { bits.set(i * BYTE_BITS_SIZE + j, bitsOfByte.get(j)); } } List<Integer> result = new LinkedList<>(); for (int n = 0; n < bits.size();) { int quotient = 0; while (bits.get(n++)) { quotient++; } int remainder = 0; BitSet range = bits.get(n, n + riceParameter); for (int i = 0; i < range.size(); i++) { if (range.get(i)) { remainder += (1 << range.size() - i - 1); } } n += riceParameter; int value = (quotient << riceParameter) + remainder; result.add(value); } for (int i = result.size() - 1; i >= 0; --i) { if (result.get(i) == 0) { result.remove(i); } } return result; }  }
RiceCompression { public List<Integer> decompress(int riceParameter, byte[] data) { BitSet bits = new BitSet(data.length * 8); for (int i = 0; i < data.length; i++) { BitSet bitsOfByte = BitSet.valueOf(makeArrayOfByte(data[i])); for (int j = 0; j < bitsOfByte.size(); j++) { bits.set(i * BYTE_BITS_SIZE + j, bitsOfByte.get(j)); } } List<Integer> result = new LinkedList<>(); for (int n = 0; n < bits.size();) { int quotient = 0; while (bits.get(n++)) { quotient++; } int remainder = 0; BitSet range = bits.get(n, n + riceParameter); for (int i = 0; i < range.size(); i++) { if (range.get(i)) { remainder += (1 << range.size() - i - 1); } } n += riceParameter; int value = (quotient << riceParameter) + remainder; result.add(value); } for (int i = result.size() - 1; i >= 0; --i) { if (result.get(i) == 0) { result.remove(i); } } return result; }  List<Integer> decompress(int riceParameter, byte[] data); }
RiceCompression { public List<Integer> decompress(int riceParameter, byte[] data) { BitSet bits = new BitSet(data.length * 8); for (int i = 0; i < data.length; i++) { BitSet bitsOfByte = BitSet.valueOf(makeArrayOfByte(data[i])); for (int j = 0; j < bitsOfByte.size(); j++) { bits.set(i * BYTE_BITS_SIZE + j, bitsOfByte.get(j)); } } List<Integer> result = new LinkedList<>(); for (int n = 0; n < bits.size();) { int quotient = 0; while (bits.get(n++)) { quotient++; } int remainder = 0; BitSet range = bits.get(n, n + riceParameter); for (int i = 0; i < range.size(); i++) { if (range.get(i)) { remainder += (1 << range.size() - i - 1); } } n += riceParameter; int value = (quotient << riceParameter) + remainder; result.add(value); } for (int i = result.size() - 1; i >= 0; --i) { if (result.get(i) == 0) { result.remove(i); } } return result; }  List<Integer> decompress(int riceParameter, byte[] data); static final int BYTE_BITS_SIZE; }