public int hashCode() { long h = 0x9e3779b97f4a7c13L ^ length; final int numWords = numWords( length ); for( int i = 0; i < numWords; i++ ) h ^= ( h << 5 ) + bits[ i ] + ( h >>> 2 ); if ( ASSERTS ) assert (int)( ( h >>> 32 ) ^ h ) == super.hashCode(); return (int)( ( h >>> 32 ) ^ h ); }
public int hashCode() { long h = 0x9e3779b97f4a7c13L ^ length; final int numWords = numWords( length ); for( int i = 0; i < numWords; i++ ) h ^= ( h << 5 ) + bits[ i ] + ( h >>> 2 ); if ( ASSERTS ) assert (int)( ( h >>> 32 ) ^ h ) == super.hashCode(); return (int)( ( h >>> 32 ) ^ h ); }
private void writeObject( final ObjectOutputStream s ) throws IOException { s.defaultWriteObject(); final int numWords = numWords( length ); for( int i = 0; i < numWords; i++ ) s.writeLong( bits[ i ] ); }
private void readObject( final ObjectInputStream s ) throws IOException, ClassNotFoundException { s.defaultReadObject(); final int numWords = numWords( length ); bits = new long[ numWords ]; for( int i = 0; i < numWords; i++ ) bits[ i ] = s.readLong(); }
public long count() { long c = 0; for( int i = numWords( length ); i-- != 0; ) c += Fast.count( bits[ i ] ); return c; }
@Override public LongArrayBitVector copy() { final LongArrayBitVector copy = new LongArrayBitVector(length); copy.length = length; System.arraycopy(bits, 0, copy.bits, 0, numWords(length)); return copy; }
public boolean equals( final LongArrayBitVector v ) { if ( length != v.length() ) return false; int i = numWords( length ); while( i-- != 0 ) if ( bits[ i ] != v.bits[ i ] ) return false; return true; }
public LongArrayBitVector copy() { LongArrayBitVector copy = new LongArrayBitVector( length ); copy.length = length; System.arraycopy( bits, 0, copy.bits, 0, numWords( length ) ); return copy; }
public boolean equals( final LongArrayBitVector v ) { if ( length != v.length() ) return false; int i = numWords( length ); while( i-- != 0 ) if ( bits[ i ] != v.bits[ i ] ) return false; return true; }
public LongArrayBitVector copy() { LongArrayBitVector copy = new LongArrayBitVector( length ); copy.length = length; System.arraycopy( bits, 0, copy.bits, 0, numWords( length ) ); return copy; }
public long nextOne( final long index ) { if ( index >= length ) return -1; final long[] bits = this.bits; final long words = numWords( length ); final int from = word( index ); final long maskedFirstWord = bits[ from ] & -( 1L << bit( index ) ); if ( maskedFirstWord != 0 ) return from * BITS_PER_WORD + Fast.leastSignificantBit( maskedFirstWord ); for ( int i = from + 1; i < words; i++ ) if ( bits[ i ] != 0 ) return i * BITS_PER_WORD + Fast.leastSignificantBit( bits[ i ] ); return -1; }