BitsetsNET.RLEBitset.Equals C# (CSharp) Method

Equals() public method

Determines if the other IBitset is equal to this one.
public Equals ( object otherSet ) : bool
otherSet object the other IBitset
return bool
        public override bool Equals(object otherSet)
        {
            bool rtnVal = false;
            if ((otherSet is RLEBitset))
            {
                RLEBitset otherRLESet = (RLEBitset)otherSet; // cast to an RLEBitset - errors if cannot cast

                if (this.length == otherRLESet.length &&
                this.runArray.Count == otherRLESet.runArray.Count)
                {

                    if (this.runArray.Count == 0)
                    {
                        rtnVal = true;
                    }

                    for (int i = 0; i < this.runArray.Count; i++)
                    {
                        if (this.runArray[i].StartIndex == otherRLESet.runArray[i].StartIndex &&
                            this.runArray[i].EndIndex == otherRLESet.runArray[i].EndIndex)
                        {
                            rtnVal = true;
                        }
                        else
                        {
                            rtnVal = false;
                            break;
                        }
                    }
                }

            }

            return rtnVal;
        }