예제 #1
0
        public override bool Equals(object o)
        {
            if (o == null || !(o is Map))
            {
                return(false);
            }
            Map m = (Map)o;

            if (size() != m.size())
            {
                return(false);
            }
            for (Iterator it = keySet().iterator(); it.hasNext();)
            {
                object k = it.next();
                if (!m.containsKey(k))
                {
                    return(false);
                }
                object v1 = get(k);
                object v2 = m.get(k);
                if (!(v1 == null ? v2 == null : v1.Equals(v2)))
                {
                    return(false);
                }
            }
            return(true);
        }
예제 #2
0
 public static object getOrDefault(Map @this, object key, object def)
 {
     return(@this.containsKey(key) ? @this.get(key) : def);
 }