/** * Test method: void setValPos(int pos, long val, int bits) * Test method: long getValPos(int pos, int bits) * * @throws Exception */ public void testSetAndGetValPos() throws Exception { int pos = 60; int bits = 10; BitMap instance = new BitMap(1000L); instance.setValPos(pos, 1000, bits); long expResult = 1000L; long result = instance.getValPos(pos, bits); assertEquals(expResult, result); }
/** * Method to perform rank0 using linear scan. * * @param i Position in the bitmap. * @return Value of rank0 at specified position. */ public long getRank0(int i) { long count = 0; for (int k = 0; k <= i; k++) { if (this.getBit(k) == 0) count++; } return count; }
/** * Test method: void bitmapSize() * * @throws Exception */ public void testBitmapSize() throws Exception { BitMap instance = new BitMap(1000L); int expectedSize = (1000 / 64) + 1; assertEquals(instance.bitmapSize(), expectedSize); }
double angle2 = Math.toRadians(angle); angle = angle2; int w = data.getWidth(); int h = data.getHeight(); int size = (int) (Math.sqrt(w * w + h * h)); BitMap newBitMap = new BitMap(size, size); int xCenter = w / 2; int yCenter = h / 2; continue; screenPixels.setValue(x, y, data.getValue(xData, yData));
/** * Test method: void clear() * * @throws Exception */ public void testClear() throws Exception { BitMap instance = new BitMap(1000L); for (int i = 0; i < 1000; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); } } instance.clear(); for (int i = 0; i < 1000; i++) { assertEquals(instance.getBit(i), 0L); } }
if (bitMap.getBit(i) == 1) { count++; this.bitMap = new BitMap(compSize); long numBits = 0; for (i = 0; i < dict.size(); i++) { if (i % 2 == 0) { this.bitMap.setValPos((int) numBits, dict.get(i), 4); numBits += 4; } else { this.bitMap.setValPos((int) numBits, dict.get(i), Tables.offsetBits[dict.get(i - 1)]); numBits += Tables.offsetBits[dict.get(i - 1)];
/** * Test method: LongBuffer getLongBuffer() * * @throws Exception */ public void testGetLongBuffer() throws Exception { BitMap instance = new BitMap(1000L); for (int i = 0; i < 1000; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); } } LongBuffer bBuf = instance.getLongBuffer(); assertNotNull(bBuf); for (int i = 0; i < instance.bitmapSize(); i++) { assertEquals(bBuf.get(i), instance.data[i]); } }
/** * Test method: void setBit(int pos) * Test method: long getBit(int pos) * * @throws Exception */ public void testSetAndGetBit() throws Exception { BitMap instance = new BitMap(1000L); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 1000; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); test.add(1L); } else { test.add(0L); } } for (int i = 0; i < 1000; i++) { long expResult = test.get(i); long result = instance.getBit(i); assertEquals(expResult, result); } }
/** * Test method: long getRank1(int i) * * @throws Exception */ public void testGetRank1() throws Exception { BitMap instance = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); long count = 0; for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); count++; } test.add(count); } for (int i = 0; i < test.size(); i++) { assertEquals(instance.getRank1(i), (long) test.get(i)); } }
/** * Test method: long getRank0(int i) * * @throws Exception */ public void testGetRank0() throws Exception { BitMap instance = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); long count = 0; for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); } else { count++; } test.add(count); } for (int i = 0; i < test.size(); i++) { assertEquals(instance.getRank0(i), (long) test.get(i)); } }
/** * Test method: long getValPos(LongBuffer bitmap, int pos, int bits) * * @throws Exception */ public void testGetValPos() throws Exception { int pos = 60; int bits = 10; BitMap instance = new BitMap(1000L); instance.setValPos(pos, 1000, bits); LongBuffer bBuf = instance.getLongBuffer(); long expResult = 1000L; long result = BitMapOps.getValPos(bBuf, pos, bits); assertEquals(expResult, result); }
/** * Test method: long getSelect1(int i) * * @throws Exception */ public void testGetSelect1() throws Exception { BitMap instance = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); test.add((long) i); } } for (int i = 0; i < test.size(); i++) { assertEquals(instance.getSelect1(i), (long) test.get(i)); } }
/** * Test method: long getSelect0(int i) * * @throws Exception */ public void testGetSelect0() throws Exception { BitMap instance = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); } else { test.add((long) i); } } for (int i = 0; i < test.size(); i++) { assertEquals(instance.getSelect0(i), (long) test.get(i)); } }
/** * Test method: long getBit(LongBuffer bitmap, int i) * * @throws Exception */ public void testGetBit() throws Exception { BitMap instance = new BitMap(1000L); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 1000; i++) { if ((int) (Math.random() * 2) == 1) { instance.setBit(i); test.add(1L); } else { test.add(0L); } } LongBuffer bBuf = instance.getLongBuffer(); for (int i = 0; i < 1000; i++) { long expResult = test.get(i); long result = BitMapOps.getBit(bBuf, i); assertEquals(expResult, result); } }
blockClass = (int) bitMap.getValPos((int) pos, 4); pos += 4; blockOffset = (int) ((blockClass == 0) ? bitMap.getBit((int) pos) * 16 : 0); pos += Tables.offsetBits[blockClass]; res += blockClass + blockOffset; blockClass = (int) bitMap.getValPos((int) pos, 4); pos += 4; blockOffset = (int) bitMap.getValPos((int) pos, Tables.offsetBits[blockClass]); res += Tables.smallRank[Tables.decodeTable[blockClass][blockOffset]][l1Idx];
/** * Test method: ByteBuffer getByteBuffer() * * @throws Exception */ public void testGetByteBuffer() throws Exception { BitMap B = new BitMap(2048); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } } ByteBuffer instance = new Dictionary(B).getByteBuffer(); assertNotNull(instance); } }
/** * Test method: long getRank1(int i) * * @throws Exception */ public void testGetRank1() throws Exception { BitMap B = new BitMap(2048); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } } Dictionary instance = new Dictionary(B); for (int i = 0; i < 2048; i++) { assertEquals(B.getRank1(i), instance.getRank1(i)); } }
/** * Test method: long getRank0(int i) * * @throws Exception */ public void testGetRank0() throws Exception { BitMap B = new BitMap(2048); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } } Dictionary instance = new Dictionary(B); for (int i = 0; i < 2048; i++) { assertEquals(B.getRank0(i), instance.getRank0(i)); } }
/** * Test method: getSelect0(ByteBuffer buf, int startPos, int i) * * @throws Exception */ public void testGetSelect0() throws Exception { BitMap B = new BitMap(2048); ArrayList<Long> test = new ArrayList<Long>(); for (int i = 0; i < 2048; i++) { if ((int) (Math.random() * 2) == 1) { B.setBit(i); } else { test.add((long) i); } } Dictionary D = new Dictionary(B); ByteBuffer dBuf = D.getByteBuffer(); for (int i = 0; i < test.size(); i++) { assertEquals(DictionaryOps.getSelect0(dBuf, 0, i), (long) test.get(i)); } } }