CollisionChecker { public boolean check(long time, int location) { if(currentInstant != time) { currentInstant = time; bitSet.clear(); } if(bitSet.get(location)) { return false; } bitSet.set(location); return true; } CollisionChecker(); boolean check(long time, int location);  }
@Test public void testCheck() throws Exception { CollisionChecker collisionChecker = new CollisionChecker(); Assert.assertTrue(collisionChecker.check(100, 1)); Assert.assertFalse(collisionChecker.check(100, 1)); for (int i = 0; i < 1000; i++) { Assert.assertTrue(collisionChecker.check(101, i)); Assert.assertFalse(collisionChecker.check(101, i)); } }