Java Code Examples for it.unimi.dsi.bits.LongArrayBitVector#getInstance()
The following examples show how to use
it.unimi.dsi.bits.LongArrayBitVector#getInstance() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LongArrayBitVectorTest.java From database with GNU General Public License v2.0 | 6 votes |
public void testCopyAnotherVector() { Random r = new Random( 1 ); LongArrayBitVector bv = LongArrayBitVector.getInstance( 200 ); for( int i = 0; i < 100; i++ ) bv.add( r.nextBoolean() ); assertEquals( LongArrayBitVector.copy( bv ), bv ); bv = LongArrayBitVector.getInstance( 256 ); for( int i = 0; i < 256; i++ ) bv.add( r.nextBoolean() ); assertEquals( LongArrayBitVector.copy( bv ), bv ); bv = LongArrayBitVector.getInstance( 10 ); for( int i = 0; i < 10; i++ ) bv.add( r.nextBoolean() ); assertEquals( LongArrayBitVector.copy( bv ), bv ); BooleanListBitVector bbv = BooleanListBitVector.getInstance( 200 ); for( int i = 0; i < 100; i++ ) bbv.add( r.nextBoolean() ); assertEquals( LongArrayBitVector.copy( bbv ), bbv ); bbv = BooleanListBitVector.getInstance( 256 ); for( int i = 0; i < 256; i++ ) bbv.add( r.nextBoolean() ); assertEquals( LongArrayBitVector.copy( bbv ), bbv ); bbv = BooleanListBitVector.getInstance( 10 ); for( int i = 0; i < 10; i++ ) bbv.add( r.nextBoolean() ); assertEquals( LongArrayBitVector.copy( bbv ), bbv ); }
Example 2
Source File: PrefixFreeTransformationStrategyTest.java From database with GNU General Public License v2.0 | 6 votes |
public void testGetLong() { LongArrayBitVector v = LongArrayBitVector.getInstance(); v.append( 0xFFFFFFFFL, 32 ); TransformationStrategy<BitVector> prefixFree = TransformationStrategies.prefixFree(); BitVector p = prefixFree.toBitVector( v ); assertEquals( 0xFFFFFFFFFFFFFFFFL, p.getLong( 0, 64 ) ); assertFalse( p.getBoolean( 64 ) ); v.clear(); v.append( 0x0, 32 ); assertEquals( 0x5555555555555555L, p.getLong( 0, 64 ) ); assertFalse( p.getBoolean( 64 ) ); v.clear(); v.append( 0x3, 32 ); assertEquals( 0x555555555555555FL, p.getLong( 0, 64 ) ); assertEquals( 0x5FL, p.getLong( 0, 7 ) ); }
Example 3
Source File: LongArrayBitVectorTest.java From database with GNU General Public License v2.0 | 5 votes |
public void testSetClearFlip() { LongArrayBitVector v = LongArrayBitVector.getInstance(); v.size( 1 ); BitVectorTestCase.testSetClearFlip( v ); v.size( 64 ); BitVectorTestCase.testSetClearFlip( v ); v.size( 80 ); BitVectorTestCase.testSetClearFlip( v ); v.size( 150 ); BitVectorTestCase.testSetClearFlip( v ); BitVectorTestCase.testSetClearFlip( v.subVector( 0, 90 ) ); BitVectorTestCase.testSetClearFlip( v.subVector( 5, 90 ) ); }
Example 4
Source File: LongArrayBitVectorTest.java From database with GNU General Public License v2.0 | 5 votes |
public void testFillFlip() { LongArrayBitVector v = LongArrayBitVector.getInstance(); v.size( 100 ); BitVectorTestCase.testFillFlip( v ); BitVectorTestCase.testFillFlip( v.subVector( 0, 90 ) ); BitVectorTestCase.testFillFlip( v.subVector( 5, 90 ) ); }
Example 5
Source File: LongArrayBitVectorTest.java From database with GNU General Public License v2.0 | 5 votes |
public void testRemove() { BitVectorTestCase.testRemove( LongArrayBitVector.getInstance() ); LongArrayBitVector v = LongArrayBitVector.getInstance(); v.clear(); v.size( 65 ); v.set( 64 ); v.removeBoolean( 0 ); assertEquals( 0, v.bits()[ 1 ] ); v.clear(); }
Example 6
Source File: BitVectorTestCase.java From database with GNU General Public License v2.0 | 5 votes |
public static void testReplace( BitVector b ) { Random r = new Random( 1 ); LongArrayBitVector bv = LongArrayBitVector.getInstance( 200 ); for( int i = 0; i < 100; i++ ) bv.add( r.nextBoolean() ); assertEquals( b.replace( bv ), bv ); bv = LongArrayBitVector.getInstance( 256 ); for( int i = 0; i < 256; i++ ) bv.add( r.nextBoolean() ); assertEquals( b.replace( bv ), bv ); bv = LongArrayBitVector.getInstance( 10 ); for( int i = 0; i < 10; i++ ) bv.add( r.nextBoolean() ); assertEquals( b.replace( bv ), bv ); }
Example 7
Source File: BitVectorsTest.java From database with GNU General Public License v2.0 | 5 votes |
public void testMakeOffline() throws IOException { final BitVector[] a = new BitVector[] { BitVectors.ZERO, BitVectors.ONE, BitVectors.EMPTY_VECTOR, LongArrayBitVector.wrap( new long[] { 0xAAAAAAAAAAAAAAAAL }, 64 ), LongArrayBitVector.wrap( new long[] { 0xAAAAAAAAAAAAAAAL }, 60 ), LongArrayBitVector.wrap( new long[] { 0xAAAAAAAAAAAAAAAAL, 0xAAAAAAAAAAAAAAAAL }, 128 ), LongArrayBitVector.wrap( new long[] { 0xAAAAAAAAAAAAAAAAL, 0xAAAAAAAAAAAAAAAL }, 124 ) }; OfflineIterable<BitVector,LongArrayBitVector> iterable = new OfflineIterable<BitVector, LongArrayBitVector>( BitVectors.OFFLINE_SERIALIZER, LongArrayBitVector.getInstance() ); iterable.addAll( Arrays.asList( a ) ); Iterator<LongArrayBitVector> iterator = iterable.iterator(); for( int i = 0; i < a.length; i++ ) assertEquals( a[ i ], iterator.next() ); assertFalse( iterator.hasNext() ); }
Example 8
Source File: LongArrayBitVectorTest.java From database with GNU General Public License v2.0 | 4 votes |
public void testLongBig() { LongArrayBitVector v = LongArrayBitVector.getInstance( 16 * 1024 ); LongBigList l = v.asLongBigList( Short.SIZE ); l.set( 0, 511 ); assertEquals( 511, v.bits()[ 0 ] ); }
Example 9
Source File: BitVectorTestCase.java From database with GNU General Public License v2.0 | 4 votes |
public static void testCopy( final BitVector v ) { v.clear(); v.size( 100 ); v.fill( 5, 80, true ); BitVector w = v.copy( 0, 85 ); assertEquals( w, v.subVector( 0, 85 ).copy() ); for( int i = w.size(); i-- != 0; ) assertEquals( i >= 5 && i < 80, w.getBoolean( i ) ); w = v.copy( 5, 85 ); assertEquals( w, v.subVector( 5, 85 ).copy() ); for( int i = w.size(); i-- != 0; ) assertEquals( i < 75, w.getBoolean( i ) ); v.clear(); int[] bits = { 0,0,0,0,1,1,1,0,0,0,0,1,1,0,0 }; for( int i = 0; i < bits.length; i++ ) v.add( bits[ i ] ); LongArrayBitVector c = LongArrayBitVector.getInstance(); for( int i = 5; i < bits.length; i++ ) c.add( bits[ i ] ); assertEquals( c, v.copy( 5, 15 ) ); assertEquals( c, v.subVector( 5, 15 ).copy() ); v.clear(); bits = new int[] { 0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,0,0 }; for( int i = 0; i < bits.length; i++ ) v.add( bits[ i ] ); c = LongArrayBitVector.getInstance(); for( int i = 5; i < bits.length - 2; i++ ) c.add( bits[ i ] ); assertEquals( c, v.copy( 5, bits.length - 2 ) ); assertEquals( v, v.copy() ); long[] words = new long[] { 0xDEADBEEFDEADF00DL, 0xDEADBEEFDEADF00DL, 0xDEADBEEFDEADF00DL, }; long[] copyWords16 = new long[] { 0xF00DDEADBEEFDEADL, 0xF00DDEADBEEFDEADL, 0xBEEFDEADL }; long[] copyWords32 = new long[] { 0xDEADF00DDEADBEEFL, 0xDEADF00DDEADBEEFL }; LongArrayBitVector.wrap( copyWords16, 64 * 2 + 32 ).equals( LongArrayBitVector.wrap( words, 64 * 3 ).copy( 16, 16 + 64 * 2 + 32 ) ); assertEquals( LongArrayBitVector.wrap( copyWords16, 64 * 2 + 32 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 16, 16 + 64 * 2 + 32 ) ); copyWords16[ 2 ] &= 0xFFFF; assertEquals( LongArrayBitVector.wrap( copyWords16, 64 * 2 + 16 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 16, 16 + 64 * 2 + 16 ) ); copyWords16[ 2 ] &= 0xFF; assertEquals( LongArrayBitVector.wrap( copyWords16, 64 * 2 + 8 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 16, 16 + 64 * 2 + 8 ) ); copyWords16[ 2 ] &= 0x1F; assertEquals( LongArrayBitVector.wrap( copyWords16, 64 * 2 + 5 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 16, 16 + 64 * 2 + 5 ) ); copyWords16[ 2 ] &= 0x1; assertEquals( LongArrayBitVector.wrap( copyWords16, 64 * 2 + 1 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 16, 16 + 64 * 2 + 1 ) ); copyWords32[ 1 ] &= 0xFFFFFFFFFFFFL; assertEquals( LongArrayBitVector.wrap( copyWords32, 64 * 1 + 32 + 16 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 32, 32 + 64 + 32 + 16 ) ); copyWords32[ 1 ] &= 0xFFFFFFFFFFL; assertEquals( LongArrayBitVector.wrap( copyWords32, 64 * 1 + 32 + 8 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 32, 32 + 64 + 32 + 8 ) ); copyWords32[ 1 ] &= 0x1FFFFFFFFFL; assertEquals( LongArrayBitVector.wrap( copyWords32, 64 * 1 + 32 + 5 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 32, 32 + 64 + 32 + 5 ) ); copyWords32[ 1 ] &= 0x1FFFFFFFFL; assertEquals( LongArrayBitVector.wrap( copyWords32, 64 * 1 + 32 + 1 ), LongArrayBitVector.wrap( words, 64 * 3 ).copy( 32, 32 + 64 + 32 + 1 ) ); }