code: public static int compress(final int[] in, int currentPos, int inlength, final int out[], final int tmpoutpos) {
  		int outpos = tmpoutpos;
  		final int finalin = currentPos + inlength;
  		while (currentPos < finalin) {
  			int inoffset = compressblock(out, outpos++, in, currentPos, inlength);
  			if (inoffset == -1)
  				throw new RuntimeException("Too big a number");
  			currentPos += inoffset;
  			inlength -= inoffset;
  		}
  		return outpos - tmpoutpos;
  	}
docs: Compress an integer array using Simple16
  
  
  @param in
  array to compress
  @param currentPos
  where to start reading
  @param inlength
  how many integers to read
  @param out
  output array
  @param tmpoutpos
  location in the output array
  @return the number of 32-bit words written (in compressed form)