Package mondrian.rolap
Class BitKey.Small
- java.lang.Object
-
- mondrian.rolap.BitKey.AbstractBitKey
-
- mondrian.rolap.BitKey.Small
-
- All Implemented Interfaces:
Serializable
,Comparable<BitKey>
,Iterable<Integer>
,BitKey
- Enclosing interface:
- BitKey
public static class BitKey.Small extends BitKey.AbstractBitKey
Implementation ofBitKey
for bit counts less than 64.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface mondrian.rolap.BitKey
BitKey.AbstractBitKey, BitKey.Big, BitKey.Factory, BitKey.Mid128, BitKey.Small
-
-
Field Summary
-
Fields inherited from class mondrian.rolap.BitKey.AbstractBitKey
ChunkBitCount, Mask, WORD_MASK
-
Fields inherited from interface mondrian.rolap.BitKey
bitPositionTable, EMPTY
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BitKey
and(BitKey bitKey)
Returns the boolean AND of this bitkey and the given bitkey.BitKey
andNot(BitKey bitKey)
Returns aBitKey
containing all of the bits in thisBitSet
whose corresponding bit is NOT set in the specifiedBitSet
.int
cardinality()
Returns the number of bits set.void
clear()
Sets all of the bits in this BitKey tofalse
.void
clear(int pos)
Sets the bit specified by the index tofalse
.int
compareTo(BitKey bitKey)
protected int
compareToBig(BitKey.Big that)
BitKey
copy()
Returns a copy of this BitKey.BitKey
emptyCopy()
Returns an empty BitKey of the same type.boolean
equals(Object o)
boolean
get(int pos)
Returns the value of the bit with the specified index.int
hashCode()
boolean
intersects(BitKey bitKey)
Returns whether this BitKey has any bits in common with a given BitKey.boolean
isEmpty()
Returns true if thisBitKey
contains no bits that are set totrue
.boolean
isSuperSetOf(BitKey bitKey)
Is every bit set in the parameterbitKey
also set inthis
.Iterator<Integer>
iterator()
To say that I am happy about this algorithm (or the variations of the algorithm used for the Mid128 and Big BitKey implementations) would be a stretch.int
nextSetBit(int fromIndex)
Returns the index of the first bit that is set totrue
that occurs on or after the specified starting index.BitKey
or(BitKey bitKey)
Or the parameterBitKey
withthis
.BitKey
orNot(BitKey bitKey)
XOr the parameterBitKey
withthis
.void
set(int pos)
Sets the bit at the specified index totrue
.BitSet
toBitSet()
Returns aBitSet
with the same contents as this BitKey.String
toString()
-
Methods inherited from class mondrian.rolap.BitKey.AbstractBitKey
bit, bitCount, chunkCount, chunkPos, copyFromByte, copyFromLong, createException, set
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
set
public void set(int pos)
Description copied from interface:BitKey
Sets the bit at the specified index totrue
.
-
get
public boolean get(int pos)
Description copied from interface:BitKey
Returns the value of the bit with the specified index. The value istrue
if the bit with the indexbitIndex
is currently set in thisBitKey
; otherwise, the result isfalse
.
-
clear
public void clear(int pos)
Description copied from interface:BitKey
Sets the bit specified by the index tofalse
.
-
clear
public void clear()
Description copied from interface:BitKey
Sets all of the bits in this BitKey tofalse
.
-
cardinality
public int cardinality()
Description copied from interface:BitKey
Returns the number of bits set.- Returns:
- Number of bits set
-
or
public BitKey or(BitKey bitKey)
Description copied from interface:BitKey
Or the parameterBitKey
withthis
.- Parameters:
bitKey
- Bit key
-
orNot
public BitKey orNot(BitKey bitKey)
Description copied from interface:BitKey
XOr the parameterBitKey
withthis
.- Parameters:
bitKey
- Bit key
-
and
public BitKey and(BitKey bitKey)
Description copied from interface:BitKey
Returns the boolean AND of this bitkey and the given bitkey.- Parameters:
bitKey
- Bit key
-
andNot
public BitKey andNot(BitKey bitKey)
Description copied from interface:BitKey
Returns aBitKey
containing all of the bits in thisBitSet
whose corresponding bit is NOT set in the specifiedBitSet
.
-
isSuperSetOf
public boolean isSuperSetOf(BitKey bitKey)
Description copied from interface:BitKey
Is every bit set in the parameterbitKey
also set inthis
. If one switchesthis
with the parameterbitKey
one gets the equivalent of isSubSetOf.- Parameters:
bitKey
- Bit key
-
intersects
public boolean intersects(BitKey bitKey)
Description copied from interface:BitKey
Returns whether this BitKey has any bits in common with a given BitKey.
-
toBitSet
public BitSet toBitSet()
Description copied from interface:BitKey
Returns aBitSet
with the same contents as this BitKey.
-
iterator
public Iterator<Integer> iterator()
To say that I am happy about this algorithm (or the variations of the algorithm used for the Mid128 and Big BitKey implementations) would be a stretch. It works but there has to be a more elegant and faster one but this is the best I could come up with in a couple of hours.
-
nextSetBit
public int nextSetBit(int fromIndex)
Description copied from interface:BitKey
Returns the index of the first bit that is set totrue
that occurs on or after the specified starting index. If no such bit exists then -1 is returned. To iterate over thetrue
bits in aBitKey
, use the following loop:for (int i = bk.nextSetBit(0); i >= 0; i = bk.nextSetBit(i + 1)) { // operate on index i here }
- Parameters:
fromIndex
- the index to start checking from (inclusive)- Returns:
- the index of the next set bit
-
compareTo
public int compareTo(BitKey bitKey)
-
compareToBig
protected int compareToBig(BitKey.Big that)
-
copy
public BitKey copy()
Description copied from interface:BitKey
Returns a copy of this BitKey.- Returns:
- copy of BitKey
-
emptyCopy
public BitKey emptyCopy()
Description copied from interface:BitKey
Returns an empty BitKey of the same type. This is the same as callingBitKey.copy()
followed byBitKey.clear()
.- Returns:
- BitKey of same type
-
isEmpty
public boolean isEmpty()
Description copied from interface:BitKey
Returns true if thisBitKey
contains no bits that are set totrue
.
-
-