aboutsummaryrefslogtreecommitdiff
path: root/dotnet/Mammoth/Couscous/java/util/HashSet.cs
blob: ac10075181ce86c9e6f5cb3b014b6c1f5811b41e (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
using System.Collections.Generic;

namespace Mammoth.Couscous.java.util {
    internal class HashSet<T> : Set<T> {
        private readonly ISet<T> _set;

        internal HashSet() : this(new System.Collections.Generic.HashSet<T>()) {
        }
        
        internal HashSet(ISet<T> set) {
            _set = set;
        }
        
        public Iterator<T> iterator() {
            return ToJava.EnumeratorToIterator(_set.GetEnumerator());
        }
        
        public bool isEmpty() {
            return _set.Count == 0;
        }
        
        public int size() {
            return _set.Count;
        }

        public bool contains(object value) {
            return value is T && _set.Contains((T)value);
        }
        
        public void add(T value) {
            _set.Add(value);
        }
    }
}