lucenenet-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From synhershko <...@git.apache.org>
Subject [GitHub] lucenenet pull request #193: Completed Grouping Implementation
Date Thu, 10 Nov 2016 02:50:38 GMT
Github user synhershko commented on a diff in the pull request:

    https://github.com/apache/lucenenet/pull/193#discussion_r87320660
  
    --- Diff: src/Lucene.Net.Core/Support/HashMap.cs ---
    @@ -125,9 +140,87 @@ public TValue AddIfAbsent(TKey key, TValue value)
                 return this[key];
             }
     
    +        #region Object overrides
    +
    +        public override bool Equals(object obj)
    +        {
    +            if (obj == this)
    +                return true;
    +
    +            if (!(obj is IDictionary<TKey, TValue>))
    +                return false;
    +            IDictionary<TKey, TValue> m = (IDictionary<TKey, TValue>)obj;
    +            if (m.Count != Count)
    +                return false;
    +
    +            try
    +            {
    +                var i = GetEnumerator();
    +                while (i.MoveNext())
    +                {
    +                    KeyValuePair<TKey, TValue> e = i.Current;
    +                    TKey key = e.Key;
    +                    TValue value = e.Value;
    +                    if (value == null)
    +                    {
    +                        if (!(m[key] == null && m.ContainsKey(key)))
    +                            return false;
    +                    }
    +                    else
    +                    {
    +                        if (!value.Equals(m[key]))
    +                            return false;
    +                    }
    +                }
    +            }
    +            catch (InvalidCastException)
    +            {
    +                return false;
    +            }
    +            catch (NullReferenceException)
    --- End diff --
    
    why are you catching NullReferenceException here?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message