using Mammoth.Couscous.java.lang; using Mammoth.Couscous.java.util; namespace Mammoth.Couscous.java.util { internal class ArrayList : List { private readonly System.Collections.Generic.IList _list; internal ArrayList() : this(new System.Collections.Generic.List()) { } internal ArrayList(System.Collections.Generic.IList list) { _list = list; } internal ArrayList(List list) : this(new System.Collections.Generic.List(FromJava.IterableToEnumerable(list))) { } public Iterator iterator() { return ToJava.EnumeratorToIterator(_list.GetEnumerator()); } public bool isEmpty() { return _list.Count == 0; } public int size() { return _list.Count; } public bool contains(object value) { return value is T && _list.Contains((T) value); } public T get(int index) { if (index < 0 || index >= _list.Count) { throw new IndexOutOfBoundsException(); } else { return _list[index]; } } public List subList(int fromIndex, int toIndex) { var list = _list as System.Collections.Generic.List; if (list == null) { throw new System.NotImplementedException(); } else { return new ArrayList(list.GetRange(fromIndex, toIndex - fromIndex)); } } public void add(T value) { _list.Add(value); } public void addAll(List other) { var iterator = other.iterator(); while (iterator.hasNext()) { add(iterator.next()); } } public T remove(int index) { T value = _list[index]; _list.RemoveAt(index); return value; } public void set(int index, T value) { _list[index] = value; } public void clear() { _list.Clear(); } } }