// Path: src/main/java/me/lemire/integercompression/differential/IntegratedIntCompressor.java
// public class IntegratedIntCompressor {
//     SkippableIntegratedIntegerCODEC codec;
//     /**
//      * Constructor wrapping a codec.
//      * 
//      * @param c the underlying codec
//      */
//     public IntegratedIntCompressor(SkippableIntegratedIntegerCODEC c) {
//       codec = c;
//     }
//     
//     /**
//      * Constructor with default codec.
//      */
//     public IntegratedIntCompressor() {
//         codec = new SkippableIntegratedComposition(new IntegratedBinaryPacking(),
//                 new IntegratedVariableByte());
//     }
// 
//     /**
//      * Compress an array and returns the compressed result as a new array.
//      * 
//      * @param input array to be compressed
//      * @return compressed array
//      * @throws UncompressibleInputException if the data is too poorly compressible
//      */
//     public  int[] compress(int[] input) {
//         int [] compressed = new int[input.length + input.length / 100 + 1024];
//         compressed[0] = input.length;
//         IntWrapper outpos = new IntWrapper(1);
//         IntWrapper initvalue = new IntWrapper(0);
// 		try {
// 			codec.headlessCompress(input, new IntWrapper(0), input.length, compressed, outpos, initvalue);
// 		} catch (IndexOutOfBoundsException ioebe) {
// 			throw new UncompressibleInputException(
// 					"Your input is too poorly compressible with the current codec : " + codec);
// 		}
//         compressed = Arrays.copyOf(compressed,outpos.intValue());
//         return compressed;
//     }
// 
//     /**
//      * Uncompress an array and returns the uncompressed result as a new array.
//      * 
//      * @param compressed compressed array
//      * @return uncompressed array
//      */
//     public int[] uncompress(int[] compressed) {
//         int[] decompressed = new int[compressed[0]];
//         IntWrapper inpos = new IntWrapper(1);
//         codec.headlessUncompress(compressed, inpos, 
//                 compressed.length - inpos.intValue(), 
//                 decompressed, new IntWrapper(0), 
//                 decompressed.length, new IntWrapper(0));
//         return decompressed;
//     }
// 
// }
// 
// Path: src/main/java/me/lemire/integercompression/differential/SkippableIntegratedIntegerCODEC.java
// public interface SkippableIntegratedIntegerCODEC {
//     /**
//      * Compress data from an array to another array.
//      * 
//      * Both inpos and outpos are modified to represent how much data was read
//      * and written to if 12 ints (inlength = 12) are compressed to 3 ints, then
//      * inpos will be incremented by 12 while outpos will be incremented by 3 we
//      * use IntWrapper to pass the values by reference.
//      * 
//      * @param in
//      *            input array
//      * @param inpos
//      *            location in the input array
//      * @param inlength
//      *            how many integers to compress
//      * @param out
//      *            output array
//      * @param outpos
//      *            where to write in the output array
//      * @param initvalue initial value for the purpose of differential coding, the value is automatically updated 
//      */
//     public void headlessCompress(int[] in, IntWrapper inpos, int inlength, int[] out,
//             IntWrapper outpos, IntWrapper initvalue);
// 
//     /**
//      * Uncompress data from an array to another array.
//      * 
//      * Both inpos and outpos parameters are modified to indicate new positions
//      * after read/write.
//      * 
//      * @param in
//      *            array containing data in compressed form
//      * @param inpos
//      *            where to start reading in the array
//      * @param inlength
//      *            length of the compressed data (ignored by some schemes)
//      * @param out
//      *            array where to write the compressed output
//      * @param outpos
//      *            where to write the compressed output in out
//      * @param num
//      *            number of integers we want to decode, the actual number of integers decoded can be less
//      * @param initvalue initial value for the purpose of differential coding, the value is automatically updated 
//      */
//     public void headlessUncompress(int[] in, IntWrapper inpos, int inlength, int[] out,
//             IntWrapper outpos, int num, IntWrapper initvalue);
// 
// }


import java.util.ArrayList;
import me.lemire.integercompression.differential.IntegratedIntCompressor;
import me.lemire.integercompression.differential.SkippableIntegratedIntegerCODEC;
import java.io.BufferedReader;
import java.io.File;
import org.junit.Assert;
import java.io.FileReader;
import java.io.IOException;
import org.junit.Test;
		// Files.lines(Paths.get("integers.txt")).mapToInt(Integer::parseInt).toArray();
		File f = new File("src/test/resources/integers.txt");
		System.out.println("loading test data from "+ f.getAbsolutePath());
		BufferedReader bfr = new BufferedReader(new FileReader(f));
		String line;
		ArrayList<Integer> ai = new ArrayList<Integer>();
		while ((line = bfr.readLine()) != null) {
			ai.add(Integer.parseInt(line));
		}
		bfr.close();
		int[] data = new int[ai.size()];
		for (int k = 0; k < data.length; ++k)
			data[k] = ai.get(k).intValue();
		ai = null;
		// finally!
		{
			IntegratedIntCompressor iic = new IntegratedIntCompressor();
			int[] compressed = iic.compress(data);
			int[] recovered = iic.uncompress(compressed);
			Assert.assertArrayEquals(recovered, data);
		}
		for (SkippableIntegerCODEC C : codecs) {
			IntCompressor iic = new IntCompressor(C);
			int[] compressed = iic.compress(data);
			int[] recovered = iic.uncompress(compressed);
			Assert.assertArrayEquals(recovered, data);

		}
		for (SkippableIntegerCODEC C : codecs) {
			if (C instanceof SkippableIntegratedIntegerCODEC) {
// Path: src/main/java/me/lemire/integercompression/differential/IntegratedIntCompressor.java
// public class IntegratedIntCompressor {
//     SkippableIntegratedIntegerCODEC codec;
//     /**
//      * Constructor wrapping a codec.
//      * 
//      * @param c the underlying codec
//      */
//     public IntegratedIntCompressor(SkippableIntegratedIntegerCODEC c) {
//       codec = c;
//     }
//     
//     /**
//      * Constructor with default codec.
//      */
//     public IntegratedIntCompressor() {
//         codec = new SkippableIntegratedComposition(new IntegratedBinaryPacking(),
//                 new IntegratedVariableByte());
//     }
// 
//     /**
//      * Compress an array and returns the compressed result as a new array.
//      * 
//      * @param input array to be compressed
//      * @return compressed array
//      * @throws UncompressibleInputException if the data is too poorly compressible
//      */
//     public  int[] compress(int[] input) {
//         int [] compressed = new int[input.length + input.length / 100 + 1024];
//         compressed[0] = input.length;
//         IntWrapper outpos = new IntWrapper(1);
//         IntWrapper initvalue = new IntWrapper(0);
// 		try {
// 			codec.headlessCompress(input, new IntWrapper(0), input.length, compressed, outpos, initvalue);
// 		} catch (IndexOutOfBoundsException ioebe) {
// 			throw new UncompressibleInputException(
// 					"Your input is too poorly compressible with the current codec : " + codec);
// 		}
//         compressed = Arrays.copyOf(compressed,outpos.intValue());
//         return compressed;
//     }
// 
//     /**
//      * Uncompress an array and returns the uncompressed result as a new array.
//      * 
//      * @param compressed compressed array
//      * @return uncompressed array
//      */
//     public int[] uncompress(int[] compressed) {
//         int[] decompressed = new int[compressed[0]];
//         IntWrapper inpos = new IntWrapper(1);
//         codec.headlessUncompress(compressed, inpos, 
//                 compressed.length - inpos.intValue(), 
//                 decompressed, new IntWrapper(0), 
//                 decompressed.length, new IntWrapper(0));
//         return decompressed;
//     }
// 
// }
// 
// Path: src/main/java/me/lemire/integercompression/differential/SkippableIntegratedIntegerCODEC.java
// public interface SkippableIntegratedIntegerCODEC {
//     /**
//      * Compress data from an array to another array.
//      * 
//      * Both inpos and outpos are modified to represent how much data was read
//      * and written to if 12 ints (inlength = 12) are compressed to 3 ints, then
//      * inpos will be incremented by 12 while outpos will be incremented by 3 we
//      * use IntWrapper to pass the values by reference.
//      * 
//      * @param in
//      *            input array
//      * @param inpos
//      *            location in the input array
//      * @param inlength
//      *            how many integers to compress
//      * @param out
//      *            output array
//      * @param outpos
//      *            where to write in the output array
//      * @param initvalue initial value for the purpose of differential coding, the value is automatically updated 
//      */
//     public void headlessCompress(int[] in, IntWrapper inpos, int inlength, int[] out,
//             IntWrapper outpos, IntWrapper initvalue);
// 
//     /**
//      * Uncompress data from an array to another array.
//      * 
//      * Both inpos and outpos parameters are modified to indicate new positions
//      * after read/write.
//      * 
//      * @param in
//      *            array containing data in compressed form
//      * @param inpos
//      *            where to start reading in the array
//      * @param inlength
//      *            length of the compressed data (ignored by some schemes)
//      * @param out
//      *            array where to write the compressed output
//      * @param outpos
//      *            where to write the compressed output in out
//      * @param num
//      *            number of integers we want to decode, the actual number of integers decoded can be less
//      * @param initvalue initial value for the purpose of differential coding, the value is automatically updated 
//      */
//     public void headlessUncompress(int[] in, IntWrapper inpos, int inlength, int[] out,
//             IntWrapper outpos, int num, IntWrapper initvalue);
// 
// }


// Path: src/test/java/me/lemire/integercompression/ResourcedTest.java
import java.util.ArrayList;
import me.lemire.integercompression.differential.IntegratedIntCompressor;
import me.lemire.integercompression.differential.SkippableIntegratedIntegerCODEC;
import java.io.BufferedReader;
import java.io.File;
import org.junit.Assert;
import java.io.FileReader;
import java.io.IOException;
import org.junit.Test;

		// Files.lines(Paths.get("integers.txt")).mapToInt(Integer::parseInt).toArray();
		File f = new File("src/test/resources/integers.txt");
		System.out.println("loading test data from "+ f.getAbsolutePath());
		BufferedReader bfr = new BufferedReader(new FileReader(f));
		String line;
		ArrayList<Integer> ai = new ArrayList<Integer>();
		while ((line = bfr.readLine()) != null) {
			ai.add(Integer.parseInt(line));
		}
		bfr.close();
		int[] data = new int[ai.size()];
		for (int k = 0; k < data.length; ++k)
			data[k] = ai.get(k).intValue();
		ai = null;
		// finally!
		{
			IntegratedIntCompressor iic = new IntegratedIntCompressor();
			int[] compressed = iic.compress(data);
			int[] recovered = iic.uncompress(compressed);
			Assert.assertArrayEquals(recovered, data);
		}
		for (SkippableIntegerCODEC C : codecs) {
			IntCompressor iic = new IntCompressor(C);
			int[] compressed = iic.compress(data);
			int[] recovered = iic.uncompress(compressed);
			Assert.assertArrayEquals(recovered, data);

		}
		for (SkippableIntegerCODEC C : codecs) {
			if (C instanceof SkippableIntegratedIntegerCODEC) {
				IntegratedIntCompressor iic = new IntegratedIntCompressor((SkippableIntegratedIntegerCODEC) C);