so I'm initializing a Bitset variable with a length of 4. When i try to seed this Bitset with the Random's class nextBoolean method. It gives the effect of removing elements. This is more than likely my inexperience with using Bitset. But as far as my understanding each element in the Bitset variable should have a random 0 or 1. Can someone see what it is that I'm doing wrong and explain what that is?
public void seedCandidate()
{
// Randomly sets bits in the candidate
for (int i = 0; i < numVals; i++)
truthVals.set(i, rn.nextBoolean());
}
When I output the length of the bitset it gives random sizes. The length of truthVals(the Bitset variable) should be 4 which is what it got instanced to so it should be {0, 1, 2, 3}. But after the seeding from the method on top I get these different lengths. From different Bitset variables.
{1, 2, 3}, {0, 1, 2, 3}, {0}, {0, 2, 3}
Aucun commentaire:
Enregistrer un commentaire