### Question:
SegmentList { public void removeFromFirstWhen(final Predicate<T> predicate) { Segment<T> firstSeg = getFirst(); while (true) { if (firstSeg == null) { this.firstOffset = this.size = 0; return; } int removed = firstSeg.removeFromFirstWhen(predicate); if (removed == 0) { break; } this.size -= removed; this.firstOffset = firstSeg.offset; if (firstSeg.isEmpty()) { RecycleUtil.recycle(this.segments.pollFirst()); firstSeg = getFirst(); this.firstOffset = 0; } } } SegmentList(final boolean recycleSegment); T get(int index); T peekLast(); T peekFirst(); @SuppressWarnings("unchecked") void add(final T e); int size(); int segmentSize(); boolean isEmpty(); void removeFromFirstWhen(final Predicate<T> predicate); void clear(); void removeFromLastWhen(final Predicate<T> predicate); void removeFromFirst(final int toIndex); @SuppressWarnings("unchecked") void addAll(final Collection<T> coll); @Override String toString(); static final int SEGMENT_SIZE; }### Answer:
@Test public void testRemoveFromFirstWhen() { fillList(); this.list.removeFromFirstWhen(x -> x < 200); assertEquals(800, this.list.size()); assertEquals(200, (int) this.list.get(0)); for (int i = 0; i < 800; i++) { assertEquals(200 + i, (int) this.list.get(i)); } this.list.removeFromFirstWhen(x -> x < 500); assertEquals(500, this.list.size()); for (int i = 0; i < 500; i++) { assertEquals(500 + i, (int) this.list.get(i)); } this.list.removeFromFirstWhen(x -> x < 1000); assertTrue(this.list.isEmpty()); assertEquals(0, this.list.segmentSize()); fillList(); assertFilledList(); }