@Test(expected = IndexOutOfBoundsException.class) public void test_SetZeroIndexOnEmpty() { AccordionList<String> list = new AccordionList<>(); list.set(0, "a", 1); }
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))); for (int i = entryIndex + 1; i < mRangeList.size(); i++) { mRangeList.set(i, mRangeList.get(i).offset(offset)); } }
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))); for (int i = entryIndex + 1; i < mRangeList.size(); i++) { mRangeList.set(i, mRangeList.get(i).offset(offset)); } } }
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))); for (int i = entryIndex + 1; i < mRangeList.size(); i++) { mRangeList.set(i, mRangeList.get(i).offset(offset)); } }  }
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))); for (int i = entryIndex + 1; i < mRangeList.size(); i++) { mRangeList.set(i, mRangeList.get(i).offset(offset)); } }  @NonNull @Override Iterator<RangedValue<T>> iterator(); @Override int hashCode(); @Override boolean equals(Object object); @NonNull T valueAt(int location); @NonNull RangedValue<T> rangedValueAt(int location); @NonNull RangedValue<T> get(int entryIndex); @NonNull Range span(); int size(); boolean isEmpty(); void add(@NonNull T value, int size); void add(int entryIndex, @NonNull T value, int size); void addAll(@NonNull AccordionList<T> values); void set(int entryIndex, @NonNull T value, int size); void clear(); void remove(int entryIndex); }
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))); for (int i = entryIndex + 1; i < mRangeList.size(); i++) { mRangeList.set(i, mRangeList.get(i).offset(offset)); } }  @NonNull @Override Iterator<RangedValue<T>> iterator(); @Override int hashCode(); @Override boolean equals(Object object); @NonNull T valueAt(int location); @NonNull RangedValue<T> rangedValueAt(int location); @NonNull RangedValue<T> get(int entryIndex); @NonNull Range span(); int size(); boolean isEmpty(); void add(@NonNull T value, int size); void add(int entryIndex, @NonNull T value, int size); void addAll(@NonNull AccordionList<T> values); void set(int entryIndex, @NonNull T value, int size); void clear(); void remove(int entryIndex);  }