@SuppressWarnings("unchecked")
    public void addAll(final Collection<T> coll) {
        Object[] src = coll2Array(coll);

        int srcPos = 0;
        int srcSize = coll.size();

        Segment<T> lastSeg = getLast();
        while (srcPos < srcSize) {
            if (lastSeg == null || lastSeg.isReachEnd()) {
                lastSeg = (Segment<T>) Segment.newInstance(this.recycleSegment);
                this.segments.add(lastSeg);
            }

            int len = Math.min(lastSeg.cap(), srcSize - srcPos);
            long bytes = lastSeg.addAll(src, srcPos, len);
            srcPos += len;
            this.size += len;
            this.estimatedBytes += bytes;
        }

    }
Removes from this list all of the elements whose index is between
0, inclusive, and {@code toIndex}, exclusive.
Shifts any succeeding elements to the left (reduces their index).
jraft-core/src/main/java/com/alipay/sofa/jraft/util/SegmentList.java