AIMA.Core.Search.Adversarial.GameState.Equals C# (CSharp) Method

Equals() public method

public Equals ( Object anotherState ) : bool
anotherState Object
return bool
        public override bool Equals(Object anotherState)
        {

            if (this == anotherState)
            {
                return true;
            }
            if ((anotherState == null)
                    || (this.getClass() != anotherState.getClass()))
            {
                return false;
            }
            GameState another = (GameState)anotherState;
            Set keySet1 = state.keySet();
            Iterator i = keySet1.iterator();
            Iterator j = another.state.keySet().iterator();
            while (i.hasNext())
            {
                String key = (String)i.next();
                bool keymatched = false;
                bool valueMatched = false;
                while (j.hasNext())
                {
                    String key2 = (String)j.next();
                    if (key.Equals(key2))
                    {
                        keymatched = true;
                        if (state.get(key).Equals(another.state.get(key2)))
                        {
                            valueMatched = true;
                        }
                        break;
                    }
                }
                if (!((keymatched) && valueMatched))
                {
                    return false;
                }
            }
            return true;
        }