@Test public void test() { MockNeighborhood first = new MockNeighborhood("first"); MockNeighborhood second = new MockNeighborhood("second"); MockNeighborhood third = new MockNeighborhood("third"); List<Set<Individual>> neighborhoods = new ArrayList<>(); neighborhoods.add(first); neighborhoods.add(second); neighborhoods.add(third); NeighborhoodSchedulerRoundRobin scheduler = new NeighborhoodSchedulerRoundRobin(neighborhoods); assertEquals(scheduler.next().toString(), "first"); assertEquals(scheduler.next().toString(), "second"); assertEquals(scheduler.next().toString(), "third"); assertEquals(scheduler.next().toString(), "first"); }
@Override public Set<Individual> next() { Set<Individual> neighborhood = neighborhoods.get(nextIdx); nextIdx = (nextIdx + 1) % neighborhoods.size(); return neighborhood; }
NeighborhoodSchedulerRoundRobin implements NeighborhoodScheduler { @Override public Set<Individual> next() { Set<Individual> neighborhood = neighborhoods.get(nextIdx); nextIdx = (nextIdx + 1) % neighborhoods.size(); return neighborhood; } }
NeighborhoodSchedulerRoundRobin implements NeighborhoodScheduler { @Override public Set<Individual> next() { Set<Individual> neighborhood = neighborhoods.get(nextIdx); nextIdx = (nextIdx + 1) % neighborhoods.size(); return neighborhood; } NeighborhoodSchedulerRoundRobin(List<Set<Individual>> neighborhoods); }
NeighborhoodSchedulerRoundRobin implements NeighborhoodScheduler { @Override public Set<Individual> next() { Set<Individual> neighborhood = neighborhoods.get(nextIdx); nextIdx = (nextIdx + 1) % neighborhoods.size(); return neighborhood; } NeighborhoodSchedulerRoundRobin(List<Set<Individual>> neighborhoods); @Override Set<Individual> next(); }
NeighborhoodSchedulerRoundRobin implements NeighborhoodScheduler { @Override public Set<Individual> next() { Set<Individual> neighborhood = neighborhoods.get(nextIdx); nextIdx = (nextIdx + 1) % neighborhoods.size(); return neighborhood; } NeighborhoodSchedulerRoundRobin(List<Set<Individual>> neighborhoods); @Override Set<Individual> next();  }