### Question:
SolutionGroup { public int removeExpired(final long now) { int removed = 0; LList<SolutionPattern> cur = solutions, prev = null; while (!cur.isNil()) { SolutionPattern curPs = cur.getValue(); if (curPs.isExpired(now)) { removed++; if (null == prev) { solutions = cur.getRest(); } else { prev.setRest(cur.getRest()); } cur = cur.getRest(); continue; } prev = cur; cur = cur.getRest(); } return removed; } SolutionGroup(Bindings<T> bindings); Bindings<T> getBindings(); LList<SolutionPattern> getSolutions(); boolean add(final Solution<T> sol,
                       final long now); int removeExpired(final long now); @Override int hashCode(); @Override boolean equals(final Object other);  }### Answer:
@Test public void testRemoveExpired() throws Exception { now = 42; Solution<String> solExp1 = new Solution<>(5, 0, bindings, now + 1000L * 10); Solution<String> solExp2 = new Solution<>(new Solution<>(5, 1, bindings, now + 1000L * 5), 2); Solution<String> solNonExp1 = new Solution<>(new Solution<>(5, 4, bindings, 0), 1); Solution<String> solNonExp2 = new Solution<>(new Solution<>(5, 3, bindings, 0), 1); Solution<String> solExp3 = new Solution<>(5, new Solution<>(5, 3, bindings, 0), new Solution<>(5, 4, bindings, now + 1000L * 20)); SolutionGroup<String> g = new SolutionGroup<>(bindings); g.add(solExp1, now); g.add(solExp2, now); g.add(solNonExp1, now); g.add(solNonExp2, now); g.add(solExp3, now); assertEquals(5, g.getSolutions().length()); g.removeExpired(now); assertEquals(5, g.getSolutions().length()); now += 1000L * 6; g.removeExpired(now); assertEquals(4, g.getSolutions().length()); now += 1000L * 5; g.removeExpired(now); assertEquals(3, g.getSolutions().length()); now += 1000L * 10; g.removeExpired(now); assertEquals(2, g.getSolutions().length()); }