mirror of
https://github.com/corda/corda.git
synced 2025-06-13 12:48:18 +00:00
Adding cardinality() to BitSet.
This commit is contained in:
@ -182,4 +182,12 @@ public class BitSet implements Serializable, Cloneable {
|
||||
return nextBit(fromIndex, true);
|
||||
}
|
||||
|
||||
public int cardinality() {
|
||||
int numSetBits = 0;
|
||||
for (int i = nextSetBit(0); i >= 0; i = nextSetBit(i+1)) {
|
||||
++numSetBits;
|
||||
}
|
||||
|
||||
return numSetBits;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user