Skip to content

Commit 1c31823

Browse files
committed
java - refactor IterTools
1 parent 1f458d5 commit 1c31823

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+473
-427
lines changed

src/main/java/AoC2015_01.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import static com.github.pareronia.aoc.AssertUtils.unreachable;
2-
import static com.github.pareronia.aoc.IterTools.enumerate;
2+
import static com.github.pareronia.aoc.itertools.IterTools.enumerate;
33
import static java.util.stream.Collectors.toList;
44

5-
import java.util.List;
6-
import java.util.function.Predicate;
7-
import java.util.stream.Collector;
8-
import java.util.stream.Collectors;
9-
105
import com.github.pareronia.aoc.Utils;
116
import com.github.pareronia.aoc.solution.Sample;
127
import com.github.pareronia.aoc.solution.Samples;
138
import com.github.pareronia.aoc.solution.SolutionBase;
149

10+
import java.util.List;
11+
import java.util.function.Predicate;
12+
import java.util.stream.Collector;
13+
import java.util.stream.Collectors;
14+
1515
public final class AoC2015_01
1616
extends SolutionBase<List<AoC2015_01.Direction>, Integer, Integer> {
1717

@@ -51,7 +51,7 @@ public boolean test(final Direction dir) {
5151
return sum != -1;
5252
}
5353
};
54-
return enumerate(input.stream())
54+
return enumerate(input).stream()
5555
.dropWhile(e -> dropCondition.test(e.value()))
5656
.map(e -> e.index() + 1)
5757
.findFirst().orElseThrow();

src/main/java/AoC2015_09.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Map;
44
import java.util.stream.IntStream;
55

6-
import com.github.pareronia.aoc.IterTools;
76
import com.github.pareronia.aoc.MutableInt;
7+
import com.github.pareronia.aoc.itertools.IterTools;
88
import com.github.pareronia.aoc.solution.Sample;
99
import com.github.pareronia.aoc.solution.Samples;
1010
import com.github.pareronia.aoc.solution.SolutionBase;

src/main/java/AoC2015_10.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import static com.github.pareronia.aoc.IterTools.enumerate;
21
import static com.github.pareronia.aoc.StringOps.splitLines;
2+
import static com.github.pareronia.aoc.itertools.IterTools.enumerate;
33
import static java.util.stream.Collectors.toMap;
44

5+
import com.github.pareronia.aoc.itertools.Enumerated;
6+
import com.github.pareronia.aoc.solution.SolutionBase;
7+
58
import java.util.Arrays;
69
import java.util.List;
710
import java.util.Map;
811

9-
import com.github.pareronia.aoc.IterTools.Enumerated;
10-
import com.github.pareronia.aoc.solution.SolutionBase;
11-
1212
public class AoC2015_10 extends SolutionBase<AoC2015_10.Input, Integer, Integer> {
1313

1414
private AoC2015_10(final boolean debug) {
@@ -28,11 +28,11 @@ protected Input parseInput(final List<String> inputs) {
2828
final List<String[]> elements = splitLines(ELEMENTS).stream()
2929
.map(s -> s.split(" "))
3030
.toList();
31-
final Map<String, Integer> indices = enumerate(elements.stream())
31+
final Map<String, Integer> indices = enumerate(elements).stream()
3232
.collect(toMap(e -> e.value()[2], Enumerated::index));
3333
final String[] sequence = new String[N];
3434
final int[][] decays = new int[N][];
35-
enumerate(elements.stream()).forEach(e -> {
35+
enumerate(elements.stream()).stream().forEach(e -> {
3636
sequence[e.index()] = e.value()[0];
3737
decays[e.index()] = Arrays.stream(e.value())
3838
.skip(4).mapToInt(indices::get).toArray();

src/main/java/AoC2015_13.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Map;
44
import java.util.stream.IntStream;
55

6-
import com.github.pareronia.aoc.IterTools;
76
import com.github.pareronia.aoc.MutableInt;
7+
import com.github.pareronia.aoc.itertools.IterTools;
88
import com.github.pareronia.aoc.solution.Sample;
99
import com.github.pareronia.aoc.solution.Samples;
1010
import com.github.pareronia.aoc.solution.SolutionBase;

src/main/java/AoC2015_17.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import static com.github.pareronia.aoc.IterTools.combinations;
21
import static com.github.pareronia.aoc.StringOps.splitLines;
2+
import static com.github.pareronia.aoc.itertools.IterTools.combinations;
33
import static java.util.Comparator.reverseOrder;
44
import static java.util.stream.Collectors.toList;
55

src/main/java/AoC2015_21.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import static com.github.pareronia.aoc.IterTools.combinations;
1+
import static com.github.pareronia.aoc.itertools.IterTools.combinations;
22
import static java.util.Collections.singleton;
33
import static java.util.Comparator.comparing;
44
import static java.util.stream.Collectors.toList;

src/main/java/AoC2016_08.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
import com.github.pareronia.aoc.CharGrid;
1010
import com.github.pareronia.aoc.Grid.Cell;
11-
import com.github.pareronia.aoc.IterTools;
1211
import com.github.pareronia.aoc.OCR;
1312
import com.github.pareronia.aoc.StringOps.StringSplit;
13+
import com.github.pareronia.aoc.itertools.IterTools;
1414
import com.github.pareronia.aoc.StringUtils;
1515
import com.github.pareronia.aoc.solution.SolutionBase;
1616

src/main/java/AoC2016_11.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import static com.github.pareronia.aoc.AssertUtils.unreachable;
2-
import static com.github.pareronia.aoc.IterTools.combinations;
2+
import static com.github.pareronia.aoc.itertools.IterTools.combinations;
33
import static java.util.Collections.emptyList;
44
import static java.util.stream.Collectors.groupingBy;
55
import static java.util.stream.Collectors.toList;

src/main/java/AoC2016_24.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import static com.github.pareronia.aoc.IterTools.combinations;
2-
1+
import static com.github.pareronia.aoc.itertools.IterTools.combinations;
32
import static java.util.stream.Collectors.toList;
43
import static java.util.stream.Collectors.toMap;
54

65
import com.github.pareronia.aoc.CharGrid;
76
import com.github.pareronia.aoc.Grid.Cell;
8-
import com.github.pareronia.aoc.IterTools;
7+
import com.github.pareronia.aoc.itertools.IterTools;
98
import com.github.pareronia.aoc.StringOps;
109
import com.github.pareronia.aoc.solution.Sample;
1110
import com.github.pareronia.aoc.solution.Samples;

src/main/java/AoC2017_02.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import static com.github.pareronia.aoc.IterTools.combinations;
1+
import static com.github.pareronia.aoc.itertools.IterTools.combinations;
22

33
import com.github.pareronia.aoc.AssertUtils;
44
import com.github.pareronia.aoc.solution.Sample;

0 commit comments

Comments
 (0)