class AccordionList implements Iterable<RangedValue<T>> {

    public void set(int entryIndex, @NonNull T value, int size) {
        if (size < 0) {
            throw new IllegalArgumentException("Size cannot be negative.");
        }

        int sizeAtPosition = entryIndex == 0 ? 0 : mRangeList.get(entryIndex - 1).mRange.mUpper;
        int offset = size - mRangeList.get(entryIndex).mRange.getSize();
        mRangeList.set(
                entryIndex,
                new RangedValue<T>(value, new Range(sizeAtPosition, sizeAtPosition + size)));
        // Update following sections.
        for (int i = entryIndex + 1; i < mRangeList.size(); i++) {
            mRangeList.set(i, mRangeList.get(i).offset(offset));
        }
    }

}