From 14ac28c468ca81b645cabf21552748a46f7b21e2 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Mon, 10 Jun 2024 15:21:00 +0100 Subject: Update java-mammoth --- Mammoth/Couscous/java/util/ArrayList.cs | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'Mammoth/Couscous/java/util/ArrayList.cs') diff --git a/Mammoth/Couscous/java/util/ArrayList.cs b/Mammoth/Couscous/java/util/ArrayList.cs index 2bd3031..2e6d736 100644 --- a/Mammoth/Couscous/java/util/ArrayList.cs +++ b/Mammoth/Couscous/java/util/ArrayList.cs @@ -4,33 +4,33 @@ 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(); @@ -38,7 +38,7 @@ namespace Mammoth.Couscous.java.util { return _list[index]; } } - + public List subList(int fromIndex, int toIndex) { var list = _list as System.Collections.Generic.List; if (list == null) { @@ -47,21 +47,28 @@ namespace Mammoth.Couscous.java.util { 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(); } -- cgit v1.2.3