@@ -141,12 +141,16 @@ public static Step selectStep(Map<Slice, List<Step>> steps) {
141141 * @return slices that are start positions for future slicing
142142 */
143143 public static List <Slice > cutAllStartPositions (Pizza pizza ) {
144+ Profiler profiler = new Profiler ();
145+ System .out .println ("cutAllStartPosition start" );
144146 List <Cell > mushrooms = pizza .getCells ().stream ()
145147 .filter (cell -> cell .ingredient .equals (Ingredient .MUSHROOM ))
146148 .collect (Collectors .toList ());
149+ System .out .println ("m size = " + mushrooms .size ());
147150 List <Cell > tomatoes = pizza .getCells ().stream ()
148151 .filter (cell -> cell .ingredient .equals (Ingredient .TOMATO ))
149152 .collect (Collectors .toList ());
153+ System .out .println ("t size = " + tomatoes .size ());
150154 LOGGER .info ("cutAllStartPositions for pizza: "
151155 + "\n " + pizza
152156 + "\n mushrooms number: " + mushrooms .size ()
@@ -156,21 +160,16 @@ public static List<Slice> cutAllStartPositions(Pizza pizza) {
156160 startPositions = tomatoes .stream ()
157161 .map (Slice ::new )
158162 .collect (Collectors .toList ());
159- List <Cell > cellsToRemove = startPositions .stream ()
160- .flatMap (slice -> slice .cells .stream ())
161- .collect (Collectors .toList ());
162- pizza .getCells ().removeAll (cellsToRemove );
163+ pizza .setCells (mushrooms );
163164 } else {
164165 startPositions = mushrooms .stream ()
165166 .map (Slice ::new )
166167 .collect (Collectors .toList ());
167- List <Cell > cellsToRemove = startPositions .stream ()
168- .flatMap (slice -> slice .cells .stream ())
169- .collect (Collectors .toList ());
170- pizza .getCells ().removeAll (cellsToRemove );
168+ pizza .setCells (tomatoes );
171169 }
172170 LOGGER .info ("pizza without start positions:"
173171 + "\n " + pizza );
172+ System .out .println (profiler .measure ("cut All ss ends in " ));
174173 return startPositions ;
175174 }
176175
0 commit comments