diff options
Diffstat (limited to 'src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java')
-rw-r--r-- | src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java b/src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java new file mode 100644 index 0000000..b359cc2 --- /dev/null +++ b/src/ch/epfl/maze/physical/stragegies/reducer/BlindCaseReducer.java | |||
@@ -0,0 +1,31 @@ | |||
1 | package ch.epfl.maze.physical.stragegies.reducer; | ||
2 | |||
3 | import ch.epfl.maze.util.Direction; | ||
4 | |||
5 | import java.util.Set; | ||
6 | import java.util.stream.Collectors; | ||
7 | |||
8 | /** | ||
9 | * A blind reducer filtering possibilities case by case. | ||
10 | * | ||
11 | * @author Pacien TRAN-GIRARD | ||
12 | */ | ||
13 | public interface BlindCaseReducer extends BlindChoiceReducer { | ||
14 | |||
15 | /** | ||
16 | * Checks if the given choice should be kept or excluded by the filter. | ||
17 | * | ||
18 | * @param choice A Direction | ||
19 | * @return T(The filter should keep the given choice) | ||
20 | */ | ||
21 | boolean keepChoice(Direction choice); | ||
22 | |||
23 | @Override | ||
24 | default Set<Direction> reduce(Set<Direction> choices) { | ||
25 | return choices | ||
26 | .stream() | ||
27 | .filter(choice -> this.keepChoice(choice)) | ||
28 | .collect(Collectors.toSet()); | ||
29 | } | ||
30 | |||
31 | } | ||