package jetbrains.mps.execution.lib; /*Generated by MPS */ import java.util.AbstractList; import java.util.List; import jetbrains.mps.internal.collections.runtime.ListSequence; import java.util.ArrayList; import org.jetbrains.annotations.NotNull; public final class ClonableList<T> extends AbstractList<T> implements Cloneable { private List<T> myData; public ClonableList() { this(ListSequence.fromList(new ArrayList<T>())); } public ClonableList(List<T> inner) { myData = inner; } public ClonableList(@NotNull T value) { this(ListSequence.fromListAndArray(new ArrayList<T>(), value)); } @Override public T get(int index) { return ListSequence.fromList(myData).getElement(index); } @Override public int size() { return ListSequence.fromList(myData).count(); } @Override public T remove(int index) { return ListSequence.fromList(myData).removeElementAt(index); } @Override public void add(int index, @NotNull T object) { ListSequence.fromList(myData).insertElement(index, object); } @Override public T set(int index, @NotNull T object) { return ListSequence.fromList(myData).setElement(index, object); } @Override public ClonableList<T> clone() throws CloneNotSupportedException { ClonableList<T> result = ((ClonableList<T>) super.clone()); result.myData = ListSequence.fromList(new ArrayList<T>()); ListSequence.fromList(result.myData).addSequence(ListSequence.fromList(myData)); return result; } public List<T> getData() { return myData; } @Override public boolean equals(Object object) { if (object instanceof ClonableList) { ClonableList another = (ClonableList) object; return (((List<T>) myData)).equals(another.myData); } return false; } @Override public int hashCode() { return ((List<T>) myData).hashCode(); } }