@Test public void generate() {}
public static <T> PersistentList<T> generate( IntFunction<? extends T[]> arrayCreator, int size, IntFunction<? extends T> generator) { var array = arrayCreator.apply(0); if (array.length != 0) { throw new IllegalArgumentException("array creator not implemented correctly"); } var newArray = Arrays.copyOf(array, size); Arrays.setAll(newArray, generator); return new PersistentList<>(currentThread(), newArray, size); }
PersistentList implements List<T> { public static <T> PersistentList<T> generate( IntFunction<? extends T[]> arrayCreator, int size, IntFunction<? extends T> generator) { var array = arrayCreator.apply(0); if (array.length != 0) { throw new IllegalArgumentException("array creator not implemented correctly"); } var newArray = Arrays.copyOf(array, size); Arrays.setAll(newArray, generator); return new PersistentList<>(currentThread(), newArray, size); } }
PersistentList implements List<T> { public static <T> PersistentList<T> generate( IntFunction<? extends T[]> arrayCreator, int size, IntFunction<? extends T> generator) { var array = arrayCreator.apply(0); if (array.length != 0) { throw new IllegalArgumentException("array creator not implemented correctly"); } var newArray = Arrays.copyOf(array, size); Arrays.setAll(newArray, generator); return new PersistentList<>(currentThread(), newArray, size); } private  PersistentList(Thread ownerThread, T[] array, int size); }
PersistentList implements List<T> { public static <T> PersistentList<T> generate( IntFunction<? extends T[]> arrayCreator, int size, IntFunction<? extends T> generator) { var array = arrayCreator.apply(0); if (array.length != 0) { throw new IllegalArgumentException("array creator not implemented correctly"); } var newArray = Arrays.copyOf(array, size); Arrays.setAll(newArray, generator); return new PersistentList<>(currentThread(), newArray, size); } private  PersistentList(Thread ownerThread, T[] array, int size); static PersistentList<T> from(IntFunction<? extends T[]> arrayCreator); static PersistentList<T> generate(
      IntFunction<? extends T[]> arrayCreator, int size, IntFunction<? extends T> generator); static PersistentList<T> of(T element); @SafeVarargs static PersistentList<T> of(T... elements); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); PersistentList<T> append(T element); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); Cursor<T> cursor(); @Override Iterator<T> iterator(); @Override Object[] toArray(); @Override E[] toArray(E[] a); @Override boolean add(T t); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean addAll(int index, Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override T get(int index); @Override T set(int index, T element); @Override void add(int index, T element); @Override T remove(int index); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<T> listIterator(); @Override ListIterator<T> listIterator(int index); @Override List<T> subList(int fromIndex, int toIndex); }
PersistentList implements List<T> { public static <T> PersistentList<T> generate( IntFunction<? extends T[]> arrayCreator, int size, IntFunction<? extends T> generator) { var array = arrayCreator.apply(0); if (array.length != 0) { throw new IllegalArgumentException("array creator not implemented correctly"); } var newArray = Arrays.copyOf(array, size); Arrays.setAll(newArray, generator); return new PersistentList<>(currentThread(), newArray, size); } private  PersistentList(Thread ownerThread, T[] array, int size); static PersistentList<T> from(IntFunction<? extends T[]> arrayCreator); static PersistentList<T> generate(
      IntFunction<? extends T[]> arrayCreator, int size, IntFunction<? extends T> generator); static PersistentList<T> of(T element); @SafeVarargs static PersistentList<T> of(T... elements); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); PersistentList<T> append(T element); @Override int size(); @Override boolean isEmpty(); @Override boolean contains(Object o); Cursor<T> cursor(); @Override Iterator<T> iterator(); @Override Object[] toArray(); @Override E[] toArray(E[] a); @Override boolean add(T t); @Override boolean remove(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean addAll(Collection<? extends T> c); @Override boolean addAll(int index, Collection<? extends T> c); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override void clear(); @Override T get(int index); @Override T set(int index, T element); @Override void add(int index, T element); @Override T remove(int index); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<T> listIterator(); @Override ListIterator<T> listIterator(int index); @Override List<T> subList(int fromIndex, int toIndex);  }