aboutsummaryrefslogtreecommitdiff
path: root/Mammoth/Couscous/java/util/AbstractMap.cs
blob: f619267c2bee2511d235d3a0f8028c53779419fb (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
using System.Collections.Generic;
using System.Linq;
using Mammoth.Couscous.java.lang;

namespace Mammoth.Couscous.java.util {
    internal abstract class AbstractMap<TKey, TValue> : Map<TKey, TValue> {
        public override bool Equals(object other) {
            var otherMap = other as Map;
            if (otherMap == null) {
                return false;
            } else {
                return Equals(otherMap);
            }
        }
        
        public bool Equals(Map other) {
            var first = AsUntypedDictionary();
            var second = other.AsUntypedDictionary();
            return
                first.Count == second.Count &&
                first.Keys.Cast<object>().All(key => second.Contains(key) && first[key].Equals(second[key]));
        }
        
        public override int GetHashCode() {
            throw new System.NotSupportedException();
        }
        
        public abstract void put(TKey key, TValue value);
        public abstract bool containsKey(TKey key);
        public abstract Set<Map__Entry<TKey, TValue>> entrySet();
        public abstract Collection<TValue> values();
	
        public abstract Optional<TValue> _lookup(TKey key);
        public abstract System.Collections.Generic.IDictionary<TKey, TValue> AsDictionary();
        public abstract System.Collections.IDictionary AsUntypedDictionary();
    }
}