// Test Bits.incl staticvoid testIncl() { for (int a : samples) { for (int b : samples) {
Bits bits = new Bits();
bits.incl(a); if (a != b)
bits.incl(b); for (int i = 0; i < LENGTH; i++) assert bits.isMember(i) == (i == a || i == b);
}
}
}
// Test Bits.excl staticvoid testExcl() { for (int a : samples) { for (int b : samples) {
Bits bits = new Bits();
bits.inclRange(0, LENGTH);
bits.excl(a); if (a != b)
bits.excl(b); for (int i = 0; i < LENGTH; i++) assert !bits.isMember(i) == (i == a || i == b);
}
}
}
// Test Bits.inclRange with various ranges. staticvoid testInclRange() { for (int i = 0; i < samples.length; i++) { for (int j = i; j < samples.length; j++)
testInclRangeHelper(samples[i], samples[j]);
}
}
// Tests Bits.inclRange for the given range. staticvoid testInclRangeHelper(int from, int to) {
Bits bits = new Bits();
bits.inclRange(from, to); for (int i = 0; i < LENGTH; i++) assert bits.isMember(i) == (from <= i && i < to);
}
// Create a Bits-instance based on bits in 'ints' argument. static Bits fromInts(int[] ints) {
Bits bits = new Bits(); for (int bit = 0; bit < ints.length * 32; bit++) if ((ints[bit / 32] & (1 << (bit % 32))) != 0)
bits.incl(bit); return bits;
}
// Asserts that two Bits-instances are equal up to first 'len' bits. staticvoid assertEquals(int len, Bits a, Bits b) { for (int i = 0; i < len; i++) assert a.isMember(i) == b.isMember(i);
}
// Test Bits.nextBit staticvoid testNextBit() {
Bits bits = sampleBits();
int index = 0; for (int bit = 0; bit < LENGTH; bit++) {
int expected;
// Passed last sample index? if (index < samples.length) {
expected = samples[index]; if (bit == samples[index])
index++;
} else {
expected = -1;
}
assert bits.nextBit(bit) == expected;
}
}
// Convenience method: Generate a Bits-instance based on samples. static Bits sampleBits() {
Bits bits = new Bits(); for (int i : samples)
bits.incl(i); return bits;
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.9 Sekunden
(vorverarbeitet am 2026-06-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.