/** Wraps the given array of longs in a bit vector. * * @param array an array of longs. * @return a bit vector of size <code>array.length * Long.SIZE</code> using <code>array</code> as backing array. */ public static LongArrayBitVector wrap( final long[] array ) { return wrap( array, array.length * Long.SIZE ); }
/** Creates a new selection structure using a bit vector specified by an array of longs and a number of bits. * * @param bits an array of longs representing a bit array. * @param length the number of bits to use from <code>bits</code>. */ public SimpleSelectZero(long[] bits, long length) { this(LongArrayBitVector.wrap(bits, length)); }
/** Creates a new select structure using a long array. * * <p>The resulting structure keeps no reference to the original array. * * @param bits a long array containing the bits. * @param length the number of valid bits in <code>bits</code>. */ public SparseSelect(final long[] bits, final long length) { this(LongArrayBitVector.wrap(bits, length)); }
/** Wraps the given array of longs in a bit vector. * * @param array an array of longs. * @return a bit vector of size <code>array.length * Long.SIZE</code> using <code>array</code> as backing array. */ public static LongArrayBitVector wrap( final long[] array ) { return wrap( array, array.length * Long.SIZE ); }
/** Wraps the given array of longs in a bit vector. * * @param array an array of longs. * @return a bit vector of size <code>array.length * Long.SIZE</code> using <code>array</code> as backing array. */ public static LongArrayBitVector wrap(final long[] array) { return wrap(array, (long)array.length * Long.SIZE); }
/** Creates a new rank structure using a long array. * * <p>The resulting structure keeps no reference to the original array. * * @param bits a long array containing the bits. * @param length the number of valid bits in <code>bits</code>. */ public SparseRank(final long[] bits, final long length) { this(LongArrayBitVector.wrap(bits, length)); }
@Override public String toString() { return "[" + LongArrayBitVector.wrap(path, pathLength) + ", " + word + "]"; }
/** Creates a new selection structure using a bit vector specified by an array of longs and a number of bits. * * @param bits an array of longs representing a bit array. * @param length the number of bits to use from <code>bits</code>. */ public SimpleSelect(long[] bits, long length) { this(LongArrayBitVector.wrap(bits, length)); }
public Rank16(long[] bits, long length) { this(LongArrayBitVector.wrap(bits, length)); }
public JacobsonBalancedParentheses(final long[] bits, final long length) { this(LongArrayBitVector.wrap(bits, length)); }
public Rank11(long[] bits, long length) { this(LongArrayBitVector.wrap(bits, length)); }
public Rank9(long[] bits, long length) { this(LongArrayBitVector.wrap(bits, length)); }
/** Reads quickly a bit vector from a {@link DataInputStream}. * * <p>This method is the dual of {@link #writeFast(BitVector, DataOutputStream)}. If you * need to avoid creating a bit vector at each call, please have a look at {@link #readFast(DataInputStream, LongArrayBitVector)}. * * @param dis a data input stream. * @return the next bit vector in the stream, as saved by {@link #writeFast(BitVector, DataOutputStream)}. * @see #writeFast(BitVector, DataOutputStream) * @see #readFast(DataInputStream, LongArrayBitVector) */ public static LongArrayBitVector readFast( DataInputStream dis ) throws IOException { final long length = dis.readLong(); final long bits[] = new long[ LongArrayBitVector.numWords( length ) ]; final int l = bits.length; for( int i = 0; i < l; i++ ) bits[ i ] = dis.readLong(); return LongArrayBitVector.wrap( bits, length ); }
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); subinventory16 = LongArrayBitVector.wrap(subinventory).asLongBigList(Short.SIZE); bits = bitVector.bits(); }
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); subinventory16 = LongArrayBitVector.wrap(subinventory).asLongBigList(Short.SIZE); bits = bitVector.bits(); }
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException { s.defaultReadObject(); bits = rank9.bitVector.bits(); final BitVector v = LongArrayBitVector.wrap(subinventory); subinventoryAsShorts = v.asLongBigList(Short.SIZE); subinventoryasInts = v.asLongBigList(Integer.SIZE); }
public BitVector copy( final long from, final long to ) { BitVectors.ensureFromTo( length(), from, to ); final long length = to - from; final long l = length - length % Long.SIZE; final long bits[] = new long[ (int)( ( length + Long.SIZE - 1 ) / Long.SIZE ) ]; int i; for( i = 0; i < l; i += Long.SIZE ) bits[ i / Long.SIZE ] = getLong( from + i, from + i + Long.SIZE ); if ( i < length ) bits[ i / Long.SIZE ] = getLong( from + i, to ); return LongArrayBitVector.wrap( bits, length ); }
public BitVector copy( final long from, final long to ) { BitVectors.ensureFromTo( length(), from, to ); final long length = to - from; final long l = length - length % Long.SIZE; final long bits[] = new long[ (int)( ( length + Long.SIZE - 1 ) / Long.SIZE ) ]; int i; for( i = 0; i < l; i += Long.SIZE ) bits[ i / Long.SIZE ] = getLong( from + i, from + i + Long.SIZE ); if ( i < length ) bits[ i / Long.SIZE ] = getLong( from + i, to ); return LongArrayBitVector.wrap( bits, length ); }
@Override public BitVector copy(final long from, final long to) { BitVectors.ensureFromTo(length(), from, to); final long length = to - from; final long l = length - length % Long.SIZE; final long bits[] = new long[(int)((length + Long.SIZE - 1) / Long.SIZE)]; long i; for(i = 0; i < l; i += Long.SIZE) bits[(int)(i / Long.SIZE)] = getLong(from + i, from + i + Long.SIZE); if (i < length) bits[(int)(i / Long.SIZE)] = getLong(from + i, to); return LongArrayBitVector.wrap(bits, length); }
private void recToString( final Node n, final MutableString printPrefix, final MutableString result, final MutableString path, final int level ) { if ( n == null ) return; //System.err.println( "Called with prefix " + printPrefix ); result.append( printPrefix ).append( '(' ).append( level ).append( ')' ); if ( n.path != null ) { path.append( LongArrayBitVector.wrap( n.path, n.pathLength ) ); result.append( " path:" ).append( LongArrayBitVector.wrap( n.path, n.pathLength ) ); } if ( n.word >= 0 ) result.append( " word: " ).append( n.word ).append( " (" ).append( path ).append( ')' ); result.append( '\n' ); path.append( '0' ); recToString( n.left, printPrefix.append( '\t' ).append( "0 => " ), result, path, level + 1 ); path.charAt( path.length() - 1, '1' ); recToString( n.right, printPrefix.replace( printPrefix.length() - 5, printPrefix.length(), "1 => "), result, path, level + 1 ); path.delete( path.length() - 1, path.length() ); printPrefix.delete( printPrefix.length() - 6, printPrefix.length() ); //System.err.println( "Path now: " + path + " Going to delete from " + ( path.length() - n.pathLength)); path.delete( path.length() - n.pathLength, path.length() ); }