// lastly update the bitfield all at once
selected.or(mask);
}
+
+ public int getMaxColumn()
+ {
+ return selected.length() - 1;
+ }
+
+ public int getMinColumn()
+ {
+ return selected.get(0) ? 0 : selected.nextSetBit(0);
+ }
}
IntList selected = new IntList();
*/
public int getMax()
{
- int max = -1;
-
- for (int sel : getSelected())
+ if (selected.isEmpty())
{
- if (sel > max)
- {
- max = sel;
- }
+ return -1;
}
-
- return max;
+ return selected.getMaxColumn();
}
/**
*/
public int getMin()
{
- int min = 1000000000;
-
- for (int sel : getSelected())
+ if (selected.isEmpty())
{
- if (sel < min)
- {
- min = sel;
- }
+ return 1000000000;
}
-
- return min;
+ return selected.getMinColumn();
}
/**
cs.invertColumnSelection(1, 9);
assertEquals("[1, 4, 8]", cs.getSelected().toString());
}
+
+ @Test(groups = { "Functional" })
+ public void testMaxColumnSelection()
+ {
+ ColumnSelection cs = new ColumnSelection();
+ cs.addElement(0);
+ cs.addElement(513);
+ cs.addElement(1);
+ assertEquals(513, cs.getMax());
+ cs.removeElement(513);
+ assertEquals(1, cs.getMax());
+ cs.removeElement(1);
+ assertEquals(0, cs.getMax());
+ cs.addElement(512);
+ cs.addElement(513);
+ assertEquals(513, cs.getMax());
+
+ }
+
+ @Test(groups = { "Functional" })
+ public void testMinColumnSelection()
+ {
+ ColumnSelection cs = new ColumnSelection();
+ cs.addElement(0);
+ cs.addElement(513);
+ cs.addElement(1);
+ assertEquals(0, cs.getMin());
+ cs.removeElement(0);
+ assertEquals(1, cs.getMin());
+ cs.addElement(0);
+ assertEquals(0, cs.getMin());
+ }
}