package com.conveyal.r5.trove;

import gnu.trove.TIntCollection;
import gnu.trove.function.TIntFunction;
import gnu.trove.iterator.TIntIterator;
import gnu.trove.list.TIntList;
import gnu.trove.list.array.TIntArrayList;
import gnu.trove.procedure.TIntProcedure;

import java.util.Collection;
import java.util.Random;

/**
 * This TIntArrayList extension wraps another TIntList, and only allows extending it and retrieving values.
 * It assumes the wrapped TIntList is immutable and treats it as such.
 * NOTE that most methods will not behave as expected, as they will affect or see only the augmented part of the list,
 * not the base list. The only method that will access the base list and account for its indexes is get(). The only
 * method that should be used to modify this list is add().
 */
public class TIntAugmentedList extends TIntArrayList {

    TIntList base;

    int startIndex;

    public TIntAugmentedList(TIntList base) {
        super();
        this.base = base;
        this.startIndex = base.size();
    }

    @Override
    public int get (int index) {
        if (index < startIndex) {
            return base.get(index);
        } else {
            index -= startIndex;
            return this.get(index);
        }
    }

}
@@ -646,24 +646,25 @@
  only method
+s
  that will a
@@ -715,17 +715,31 @@
 xes 
-is
+are
  get()
-.
+ and set().%0A *
  The
@@ -747,18 +747,16 @@
 only
-%0A *
  method
+s
  tha
@@ -796,16 +796,27 @@
 ist 
-is
+are
  add()
+ and set()
 .%0A *
@@ -1199,16 +1199,32 @@
     
+return super.get(
 index -
-=
  sta
@@ -1230,16 +1230,17 @@
 artIndex
+)
 ;%0A      
@@ -1245,45 +1245,364 @@
     
+%7D%0A
     
-return this.get(index);%0A        %7D
+%7D%0A%0A    @Override%0A    public int set (int index, int value) %7B%0A        if (index %3C startIndex) %7B%0A            throw new RuntimeException(%22Modifying the base graph is not allowed.%22);%0A        %7D else %7B%0A            return super.set(index - startIndex, value);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public int size() %7B%0A        return base.size() + super.size();
 %0A   

add size and set methods to extended TIntList type