/** * Test method: void setVal(int i, long val) * Test method: long getVal(int i)* * * @throws Exception */ public void testSetAndGetVal() throws Exception { BMArray instance = new BMArray(1000, 64); for (int i = 0; i < 1000; i++) { instance.setVal(i, i); } for (int i = 0; i < 1000; i++) { long result = instance.getVal(i); assertEquals(i, result); } }
/** * Test method: long getVal(LongBuffer B, int i, int bits) * * @throws Exception */ public void testGetVal() throws Exception { BMArray bmArray = new BMArray(1000, 64); for (int i = 0; i < 1000; i++) { bmArray.setVal(i, i); } LongBuffer bBuf = bmArray.getLongBuffer(); for (int i = 0; i < 1000; i++) { assertEquals(BMArrayOps.getVal(bBuf, i, 64), i); } } }
/** * Constructor to convert a part of an integer array into a bitmap array. * * @param input Input integer array. * @param offset Beginning offset into input. * @param length Length of sub-array to convert. */ public BMArray(int[] input, int offset, int length) { super(((long) length) * ((long) CommonUtils.intLog2(length))); this.n = length; this.bits = CommonUtils.intLog2(this.n + 1); for (int i = offset; i < offset + length; i++) { this.setVal(i - offset, input[i]); } }