aboutsummaryrefslogtreecommitdiff
path: root/dotnet/Mammoth/Couscous/java/util/ArrayList.cs
blob: 4414123d65b1219457c40245499d5ae967c5f8db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;
        }
    }
}