public void removeFromFirstWhen(final Predicate<T> predicate) {
        Segment<T> firstSeg = getFirst();
        while (true) {
            if (firstSeg == null) {
                this.firstOffset = this.size = 0;
                this.estimatedBytes = 0;
                return;
            }
            long[] results = firstSeg.removeFromFirstWhen(predicate);
            int removed = (int) results[0];
            long removedBytes = results[1];
            if (removed == 0) {
                break;
            }
            this.size -= removed;
            this.estimatedBytes -= removedBytes;
            this.firstOffset = firstSeg.offset;
            if (firstSeg.isEmpty()) {
                RecycleUtil.recycle(this.segments.pollFirst());
                firstSeg = getFirst();
                this.firstOffset = 0;
            }
        }
    }
Remove elements from first until predicate returns false.

@param predicate predicate functional interface
jraft-core/src/main/java/com/alipay/sofa/jraft/util/SegmentList.java