@Test public void removalsFromAnEmptyList() { assertEquals(emptyList(), Lists.removeFrom(emptyList(), 1)); }
public static <T> List<List<T>> removeFrom(List<T> target, int howMany) { if (howMany < 0) throw new IllegalArgumentException("Can't remove " + howMany + " elements from a list"); if (howMany == 0) return singletonList(target); if (howMany > target.size()) return emptyList(); List<T> left = target.subList(0, howMany); List<T> right = target.subList(howMany, target.size()); if (right.isEmpty()) return singletonList(emptyList()); List<List<T>> removals = new ArrayList<>(); removals.add(right); removals.addAll(removeFrom(right, howMany) .stream() .map(r -> { List<T> items = new ArrayList<>(left); items.addAll(r); return items; }) .collect(toList())); return removals; }
Lists { public static <T> List<List<T>> removeFrom(List<T> target, int howMany) { if (howMany < 0) throw new IllegalArgumentException("Can't remove " + howMany + " elements from a list"); if (howMany == 0) return singletonList(target); if (howMany > target.size()) return emptyList(); List<T> left = target.subList(0, howMany); List<T> right = target.subList(howMany, target.size()); if (right.isEmpty()) return singletonList(emptyList()); List<List<T>> removals = new ArrayList<>(); removals.add(right); removals.addAll(removeFrom(right, howMany) .stream() .map(r -> { List<T> items = new ArrayList<>(left); items.addAll(r); return items; }) .collect(toList())); return removals; } }
Lists { public static <T> List<List<T>> removeFrom(List<T> target, int howMany) { if (howMany < 0) throw new IllegalArgumentException("Can't remove " + howMany + " elements from a list"); if (howMany == 0) return singletonList(target); if (howMany > target.size()) return emptyList(); List<T> left = target.subList(0, howMany); List<T> right = target.subList(howMany, target.size()); if (right.isEmpty()) return singletonList(emptyList()); List<List<T>> removals = new ArrayList<>(); removals.add(right); removals.addAll(removeFrom(right, howMany) .stream() .map(r -> { List<T> items = new ArrayList<>(left); items.addAll(r); return items; }) .collect(toList())); return removals; } private  Lists(); }
Lists { public static <T> List<List<T>> removeFrom(List<T> target, int howMany) { if (howMany < 0) throw new IllegalArgumentException("Can't remove " + howMany + " elements from a list"); if (howMany == 0) return singletonList(target); if (howMany > target.size()) return emptyList(); List<T> left = target.subList(0, howMany); List<T> right = target.subList(howMany, target.size()); if (right.isEmpty()) return singletonList(emptyList()); List<List<T>> removals = new ArrayList<>(); removals.add(right); removals.addAll(removeFrom(right, howMany) .stream() .map(r -> { List<T> items = new ArrayList<>(left); items.addAll(r); return items; }) .collect(toList())); return removals; } private  Lists(); static List<List<T>> removeFrom(List<T> target, int howMany); static List<List<T>> shrinksOfOneItem(
        SourceOfRandomness random,
        List<T> target,
        Shrink<T> shrink); static boolean isDistinct(List<T> target); }
Lists { public static <T> List<List<T>> removeFrom(List<T> target, int howMany) { if (howMany < 0) throw new IllegalArgumentException("Can't remove " + howMany + " elements from a list"); if (howMany == 0) return singletonList(target); if (howMany > target.size()) return emptyList(); List<T> left = target.subList(0, howMany); List<T> right = target.subList(howMany, target.size()); if (right.isEmpty()) return singletonList(emptyList()); List<List<T>> removals = new ArrayList<>(); removals.add(right); removals.addAll(removeFrom(right, howMany) .stream() .map(r -> { List<T> items = new ArrayList<>(left); items.addAll(r); return items; }) .collect(toList())); return removals; } private  Lists(); static List<List<T>> removeFrom(List<T> target, int howMany); static List<List<T>> shrinksOfOneItem(
        SourceOfRandomness random,
        List<T> target,
        Shrink<T> shrink); static boolean isDistinct(List<T> target);  }