diff options
| author | Michael Williamson <mike@zwobble.org> | 2016-04-30 17:20:53 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2016-04-30 17:20:53 +0100 |
| commit | ec5037c01868fecaec2eba89b975f3e53aded89a (patch) | |
| tree | e0d5a092419bace577a90eb29699f5be57f36078 /Mammoth/Couscous/java/util/ArrayList.cs | |
| parent | 17d1a1f710edd8dfb92e75bcd273e04cee7c8146 (diff) | |
Export from java-mammoth 5f538798b147f0e76
Diffstat (limited to 'Mammoth/Couscous/java/util/ArrayList.cs')
| -rw-r--r-- | Mammoth/Couscous/java/util/ArrayList.cs | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/Mammoth/Couscous/java/util/ArrayList.cs b/Mammoth/Couscous/java/util/ArrayList.cs new file mode 100644 index 0000000..4414123 --- /dev/null +++ b/Mammoth/Couscous/java/util/ArrayList.cs @@ -0,0 +1,49 @@ +using Mammoth.Couscous.java.lang; +using Mammoth.Couscous.java.util; + +namespace Mammoth.Couscous.java.util { + internal class ArrayList<T> : List<T> { + private readonly System.Collections.Generic.IList<T> _list; + + internal ArrayList() : this(new System.Collections.Generic.List<T>()) { + } + + internal ArrayList(System.Collections.Generic.IList<T> list) { + _list = list; + } + + public Iterator<T> 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 void add(T value) { + _list.Add(value); + } + + public T remove(int index) { + T value = _list[index]; + _list.RemoveAt(index); + return value; + } + } +} |
