BoolVector

public class BoolVector

A vector of booleans, indexed by an integer rank from 0 up.

Fields

B_SET_ALL

protected static final int B_SET_ALL

B_SET_ONE

protected static final int B_SET_ONE

B_SET_SIZE

protected static final short B_SET_SIZE

B_SET_ZERO

protected static final int B_SET_ZERO

bSets

protected int[] bSets

Bitset version of this Boolvector’s contents. Array of int’s that contain the booleans (32 each).

Constructors

BoolVector

public BoolVector(int size)

Creates a new BoolVector containing “size” booleans. Each boolean is initialized to false.

BoolVector

public BoolVector(boolean sparse, int size)

Creates a new BoolVector containing “size” booleans. Each boolean is initialized to false.

Methods

and

public final BoolVector and(BoolVector other)
Returns

a new BoolVector containing logical AND between this BoolVector and the “other”.

contains

public final boolean contains(TapIntList indices)
Returns

true if for each index in “indices” this BoolVector holds the value “true”.

contains

public final boolean contains(BoolVector other, int len)
Parameters
  • other – The other BoolVector that must be contained in this.

  • len – The number of booleans on which the test is restricted.

Returns

true if this BoolVector contains (or is equal to) the “other” BoolVector, considering only the “len” first bits. Same semantics as: this.and(other).equals(other,len)

copy

public final BoolVector copy()

Creates a new copy of this BoolVector.

copy

public final BoolVector copy(int len, int finalLen)

Same as copy(), but creates a Boolvector of length “finalLen”, and copies only the “len” first bits. If finalLen is relatively smaller, truncates. If finalLen is relatively larger, pads with 0’s.

cumulAnd

public final void cumulAnd(BoolVector other)

And-accumulates BoolVector “other” into this BoolVector.

cumulAnd

public final void cumulAnd(BoolVector other, int len)

Same as cumulAnd(BoolVector), but only for the “len” first bits.

cumulMinus

public final void cumulMinus(BoolVector other)

And-accumulates the negation of BoolVector “other” into this BoolVector. In other words: “this”=”this” AND NOT “other”.

cumulMinus

public final void cumulMinus(BoolVector other, int len)

Same as cumulMinus(BoolVector), but only for the “len” first bits.

cumulOr

public final void cumulOr(BoolVector other)

Or-accumulates BoolVector “other” into this BoolVector.

cumulOr

public final void cumulOr(BoolVector other, int len)

Same as cumulOr(BoolVector), but only for the “len” first bits.

cumulOr

public final void cumulOr(BoolVector newVect, int newStart, int start, int len)

Or-accumulates “len” bits of BoolVector “newVect”, starting at bit “newStart”, into this BoolVector, starting at bit “start”.

cumulOrGrows

public final boolean cumulOrGrows(BoolVector other)

Or-accumulates BoolVector “other” into this BoolVector.

Returns

true iff the accumulated BoolVector has more “true” elements.

cumulOrGrows

public final boolean cumulOrGrows(BoolVector other, int len)

Or-accumulates BoolVector “other” into this BoolVector. Same as cumulOr(BoolVector), but only for the “len” first bits, and returns true iff the accumulated BoolVector has more “true” elements, again considering only the “len” first bits.

distance

public final int distance(BoolVector other, int len)
Parameters
  • other – The other BoolVector

  • len – The number of booleans on which the test is restricted.

Returns

The number of differences.

dump

public void dump()

Prints in detail the contents of this BoolVector, onto TapEnv.curOutputStream().

dump

public void dump(int length)

Prints in detail the contents of this BoolVector, knowing its exact length, onto TapEnv.curOutputStream().

Parameters
  • length – the exact length of this BoolVector.

dump

public void dump(int[] map)

Prints in detail the contents of this BoolVector, knowing its Map, onto TapEnv.curOutputStream().

Parameters
  • map – the map of this BoolVector.

equals

public final boolean equals(BoolVector other, int len)
Parameters
  • other – The other BoolVector that must be equal to this.

  • len – The number of booleans on which the test is restricted.

Returns

true if this is equal to “other”.

get

public final boolean get(int rank)
Returns

the boolean value at rank “rank”.

getSubInt

protected static int getSubInt(int origInt, int fromBit, int toBit)
Returns

in the leftmost bits of the result a copy of the bits [fromBit;toBit[ of the given int origInt. fromBit and toBit-1 are between 0 and bSetSize-1 (e.g. 31). The remaining bits of the result are set to 0.

grossLength

public int grossLength()

intersects

public final boolean intersects(TapIntList indices)
Returns

true if there exists one index in “indices” for which this BoolVector holds the value “true”.

intersects

public final boolean intersects(BoolVector other, int len)
Parameters
  • other – The other BoolVector that must intersect this.

  • len – The number of booleans on which the test is restricted.

Returns

true if this intersects “other”.

isFalse

public final boolean isFalse(int len)
Parameters
  • len – The number of booleans on which the test is restricted.

Returns

true if this is full of 0.

isSparse

public final boolean isSparse()

maxTrueRank

public final int maxTrueRank(int len)

minus

public final BoolVector minus(BoolVector other)
Returns

a new BoolVector containing logical MINUS (i.e. AND NOT) between this BoolVector and the other.

not

public final BoolVector not()
Returns

a new BoolVector containing logical NOT of this BoolVector.

numberOfOnes

public final int numberOfOnes(int length)

(for debugging) @return the number of “true” elements in this vector.

or

public final BoolVector or(BoolVector other)
Returns

a new BoolVector containing logical OR between this BoolVector and the “other”.

set

public final void set(int rank, boolean val)

Sets the boolean value at rank “rank” to “val”.

set

public final void set(TapIntList indexes, boolean val)

Sets all indexes in “indexes” to boolean “val”.

setCopy

public final void setCopy(BoolVector model)

Sets the boolean values just like in the “model” BoolVector.

setCopy

public final void setCopy(BoolVector model, int len)

Sets the boolean values just like in the “model” BoolVector, only for the “len” first bits. The remaining bits are set to false.

setDeclared

public void setDeclared(int zone, int[] curBlockMap, boolean val)

Set the boolean info stored in this BoolVector for the “declared” zone number “zone”.

setDeclared

public void setDeclared(TapIntList zones, int[] curBlockMap, boolean val)

Set the boolean info stored in this BoolVector for the “declared” zone numbers “zones”.

setFalse

public final void setFalse()

Resets the whole BoolVector to false.

setSubInt

protected static int setSubInt(int origInt, int cpInt, int fromBit, int toBit)
Returns

a bitwise copy of the given “origInt”, in which bits [fromBit;toBit[ have been replaced by the leftmost bits of the given “cpInt”.

setTrue

public final void setTrue()

Resets the whole BoolVector to true.

toString

public final String toString(int[] map)

Builds a String describing the exact contents of this BoolVector, knowing its map.

toString

public final String toString(int size)

Builds a String describing the exact contents of this BoolVector, knowing its exact size.

toString

public final String toString()

Builds a String describing the exact contents of this BoolVector, without knowing its exact length or its map. Therefore, this displays some multiple of 32 booleans, including meaningless trailing booleans.

trueIndexList

public final TapIntList trueIndexList(int size)

Converts into the TapIntList of all the indices for which this BoolVector holds true.

xor

public final BoolVector xor(BoolVector other)
Returns

a new BoolVector containing logical XOR between this BoolVector and other.