/** * Constructs an instance. * * @param max the maximum value of ints in this set. */ public BitIntSet(int max) { bits = Bits.makeBitSet(max); }
/** * Constructs an instance. * * @param max the maximum value of ints in this set. */ public BitIntSet(int max) { bits = Bits.makeBitSet(max); }
/** * Constructs an instance. * * @param max the maximum value of ints in this set. */ public BitIntSet(int max) { bits = Bits.makeBitSet(max); }
/** * Constructs an instance. * * @param max the maximum value of ints in this set. */ public BitIntSet(int max) { bits = Bits.makeBitSet(max); }
/** * Constructs an instance. * * @param max the maximum value of ints in this set. */ public BitIntSet(int max) { bits = Bits.makeBitSet(max); }
/** * Constructs an instance. * * @param max the maximum value of ints in this set. */ public BitIntSet(int max) { bits = Bits.makeBitSet(max); }
/** * Constructs an instance. * * @param max the maximum value of ints in this set. */ public BitIntSet(int max) { bits = Bits.makeBitSet(max); }
/** * Constructs an instance. * * @param max the maximum value of ints in this set. */ public BitIntSet(int max) { bits = Bits.makeBitSet(max); }
/** * Ensures that the bit set has the capacity to represent the given value. * * @param value {@code >= 0;} value to represent */ private void ensureCapacity(int value) { if (value >= Bits.getMax(bits)) { int[] newBits = Bits.makeBitSet( Math.max(value + 1, 2 * Bits.getMax(bits))); System.arraycopy(bits, 0, newBits, 0, bits.length); bits = newBits; } }
/** * Ensures that the bit set has the capacity to represent the given value. * * @param value {@code >= 0;} value to represent */ private void ensureCapacity(int value) { if (value >= Bits.getMax(bits)) { int[] newBits = Bits.makeBitSet( Math.max(value + 1, 2 * Bits.getMax(bits))); System.arraycopy(bits, 0, newBits, 0, bits.length); bits = newBits; } }
public void test1_get() { int[] bits = Bits.makeBitSet(100); for (int i = 0; i < 100; i++) { assertFalse(label(i), Bits.get(bits, i)); } }
public void test2_get() { int[] bits = Bits.makeBitSet(100); for (int i = 0; i < bits.length; i++) { bits[i] = -1; } for (int i = 0; i < 100; i++) { assertTrue(label(i), Bits.get(bits, i)); } }
public void test2_get() { int[] bits = Bits.makeBitSet(100); for (int i = 0; i < bits.length; i++) { bits[i] = -1; } for (int i = 0; i < 100; i++) { assertTrue(label(i), Bits.get(bits, i)); } }
public void test1_get() { int[] bits = Bits.makeBitSet(100); for (int i = 0; i < 100; i++) { assertFalse(label(i), Bits.get(bits, i)); } }
public void test3_get() { int[] bits = Bits.makeBitSet(100); for (int i = 0; i < 100; i++) { Bits.set(bits, i, (i % 5) == 0); } for (int i = 0; i < 100; i++) { boolean expect = (i % 5) == 0; assertTrue(label(i), Bits.get(bits, i) == expect); } }
public void test2_isEmpty() { for (int i = 1; i < 1000; i += 11) { int[] bits = Bits.makeBitSet(i); for (int j = i % 11; j >= 0; j--) { int x = i - 1 - (j * 13); if (x >= 0) { Bits.set(bits, x); } } assertFalse(label(i), Bits.isEmpty(bits)); } }
public void test_set2() { int[] bits = Bits.makeBitSet(100); for (int i = 0; i < 100; i++) { if ((i % 11) == 0) { Bits.set(bits, i); } } for (int i = 0; i < 100; i++) { boolean expect = (i % 11) == 0; assertTrue(label(i), Bits.get(bits, i) == expect); } }
public void test2_isEmpty() { for (int i = 1; i < 1000; i += 11) { int[] bits = Bits.makeBitSet(i); for (int j = i % 11; j >= 0; j--) { int x = i - 1 - (j * 13); if (x >= 0) { Bits.set(bits, x); } } assertFalse(label(i), Bits.isEmpty(bits)); } }
public void test3_get() { int[] bits = Bits.makeBitSet(100); for (int i = 0; i < 100; i++) { Bits.set(bits, i, (i % 5) == 0); } for (int i = 0; i < 100; i++) { boolean expect = (i % 5) == 0; assertTrue(label(i), Bits.get(bits, i) == expect); } }
public void test_set2() { int[] bits = Bits.makeBitSet(100); for (int i = 0; i < 100; i++) { if ((i % 11) == 0) { Bits.set(bits, i); } } for (int i = 0; i < 100; i++) { boolean expect = (i % 11) == 0; assertTrue(label(i), Bits.get(bits, i) == expect); } }