From 0f9ef005f063198ea2e16ca36beaead4bd5e3824 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Thu, 14 Apr 2016 21:12:07 +0100 Subject: Add .NET output --- dotnet/Mammoth/Couscous/java/util/ArrayList.cs | 49 ++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 dotnet/Mammoth/Couscous/java/util/ArrayList.cs (limited to 'dotnet/Mammoth/Couscous/java/util/ArrayList.cs') diff --git a/dotnet/Mammoth/Couscous/java/util/ArrayList.cs b/dotnet/Mammoth/Couscous/java/util/ArrayList.cs new file mode 100644 index 0000000..4414123 --- /dev/null +++ b/dotnet/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 : 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; + } + + 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 void add(T value) { + _list.Add(value); + } + + public T remove(int index) { + T value = _list[index]; + _list.RemoveAt(index); + return value; + } + } +} -- cgit v1.2.3