org.limewire.collection
Class OrView
java.lang.Object
org.limewire.collection.OrView
- All Implemented Interfaces:
- BitField
public class OrView
- extends Object
Gives an Or view over one to many BitFields.
OrView returns the Or value and next clear (equal to 0) and
set (equal to 1) bit of the BitFields.
See Or for more information on
the logical disjunction.
void sampleCodeOrView(){
BitSet bs1 = new BitSet();
bs1.set(0);
bs1.set(1);
BitSet bs2 = new BitSet();
bs2.set(0);
bs2.set(2);
BitField bf1 = new BitFieldSet(bs1, 5);
BitField bf2 = new BitFieldSet(bs2, 5);
printBitField(bf1, "bf1");
printBitField(bf2, "bf2");
OrView ov = new OrView(bf1, bf2);
printBitField(ov, " ov");
}
void printBitField(BitField bf, String bfName){
System.out.print(bfName + ": ");
for(int i = 0; i < bf.maxSize(); i++){
int j = 0;
if(bf.get(i))
j = 1;
System.out.print(j);
}
System.out.println("");
}
Output:
bf1: 11000
bf2: 10100
ov: 11100
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
fields
protected final BitField[] fields
OrView
public OrView(BitField first,
BitField... more)
get
public boolean get(int i)
nextClearBit
public int nextClearBit(int startIndex)
nextSetBit
public int nextSetBit(int startIndex)
- Returns:
- index of next set bit from index
i or -1 if there is no bit left
maxSize
public int maxSize()
- Specified by:
maxSize in interface BitField
cardinality
public int cardinality()
- Specified by:
cardinality in interface BitField
Copyright © 2009 Lime Wire LLC. All Rights Reserved.