PartitionIterators { public static PartitionIterator range(ObjectGrid og, int start, int end) { int size = getPartitionSize(og); check("start", start, size); check("end", end, size); int countBy = (start < end) ? 1 : -1; return new Itr(start, end, countBy); }  static PartitionIterator ascending(ObjectGrid og); static PartitionIterator ascending(ObjectGrid og, int start); static PartitionIterator descending(ObjectGrid og); static PartitionIterator descending(ObjectGrid og, int end); static PartitionIterator range(ObjectGrid og, int start, int end); static int getPartitionSize(ObjectGrid og);  }
@Test public void testOnePartition() { PartitionIterator itr = PartitionIterators.range(ogclient, 1, 1); Assert.assertTrue("hasNext", itr.hasNext()); Assert.assertEquals("next", 1, itr.next()); Assert.assertFalse("hasNext", itr.hasNext()); }
@Test public void testRangePartition() { PartitionIterator itr = PartitionIterators.range(ogclient, 1, 3); for (int i = 1; i < 4; ++i) { Assert.assertTrue("hasNext", itr.hasNext()); Assert.assertEquals("Wrong partition", i, itr.next()); } itr = PartitionIterators.range(ogclient, 3, 1); for (int i = 3; i > 0; --i) { Assert.assertTrue("hasNext", itr.hasNext()); Assert.assertEquals("Wrong partition", i, itr.next()); } }