bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }

            var list = other as ListTuple;

            if (!object.ReferenceEquals(list, null))
            {
                if (list.m_count != m_count)
                {
                    return(false);
                }

                if (list.m_offset == 0 && list.m_count == list.m_items.Length)
                {
                    return(CompareItems(list.m_items, comparer));
                }
                else
                {
                    return(CompareItems(list, comparer));
                }
            }

            return(STuple.Equals(this, other, comparer));
        }
        bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }

            var sliced = other as SlicedTuple;

            if (!object.ReferenceEquals(sliced, null))
            {
                if (sliced.m_count != m_count)
                {
                    return(false);
                }

                // compare slices!
                for (int i = 0; i < m_count; i++)
                {
                    if (m_slices[i + m_offset] != sliced.m_slices[i + sliced.m_offset])
                    {
                        return(false);
                    }
                }
                return(false);
            }

            return(STuple.Equals(this, other, comparer));
        }
Пример #3
0
        bool System.Collections.IStructuralEquatable.Equals(object other, System.Collections.IEqualityComparer comparer)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }

            var linked = other as LinkedTuple <T>;

            if (!object.ReferenceEquals(linked, null))
            {
                // must have same length
                if (linked.Count != this.Count)
                {
                    return(false);
                }
                // compare the tail before
                if (!comparer.Equals(this.Tail, linked.Tail))
                {
                    return(false);
                }
                // compare the rest
                return(this.Head.Equals(linked.Tail, comparer));
            }

            return(STuple.Equals(this, other, comparer));
        }
Пример #4
0
 bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
 {
     if (other == null)
     {
         return(false);
     }
     if (other is STuple <T1> )
     {
         return(comparer.Equals(this.Item1, ((STuple <T1>)other).Item1));
     }
     return(STuple.Equals(this, other, comparer));
 }
Пример #5
0
 bool System.Collections.IStructuralEquatable.Equals(object other, System.Collections.IEqualityComparer comparer)
 {
     if (other == null)
     {
         return(false);
     }
     if (other is STuple <T1, T2> )
     {
         var tuple = (STuple <T1, T2>)other;
         return(comparer.Equals(this.Item1, tuple.Item1) &&
                comparer.Equals(this.Item2, tuple.Item2));
     }
     return(STuple.Equals(this, other, comparer));
 }
Пример #6
0
 bool IStructuralEquatable.Equals(object other, IEqualityComparer comparer)
 {
     if (other == null)
     {
         return(false);
     }
     if (other is STuple <T1, T2, T3> )
     {
         var tuple = (STuple <T1, T2, T3>)other;
         return(comparer.Equals(this.Item1, tuple.Item1) &&
                comparer.Equals(this.Item2, tuple.Item2) &&
                comparer.Equals(this.Item3, tuple.Item3));
     }
     return(STuple.Equals(this, other, comparer));
 }
        public bool Equals(ITuple other)
        {
            if (object.ReferenceEquals(other, null))
            {
                return(false);
            }

            var memoized = other as MemoizedTuple;

            if (!object.ReferenceEquals(memoized, null))
            {
                return(m_packed.Equals(memoized.m_packed));
            }

            return(STuple.Equals(this, other, SimilarValueComparer.Default));
        }
Пример #8
0
        bool System.Collections.IStructuralEquatable.Equals(object other, System.Collections.IEqualityComparer comparer)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }

            var linked = other as PrefixedTuple;

            if (!object.ReferenceEquals(linked, null))
            {
                // Should all of these tuples be considered equal ?
                // * Head=(A,B) + Tail=(C,)
                // * Head=(A,) + Tail=(B,C,)
                // * Head=() + Tail=(A,B,C,)

                // first check the subspaces
                if (!linked.m_prefix.Equals(m_prefix))
                {                 // they have a different prefix
                    return(false);
                }

                if (m_items.Count != linked.m_items.Count)
                {                 // there's no way they would be equal
                    return(false);
                }

                return(comparer.Equals(m_items, linked.m_items));
            }

            return(STuple.Equals(this, other, comparer));
        }
 bool IStructuralEquatable.Equals(object other, System.Collections.IEqualityComparer comparer)
 {
     return(STuple.Equals(this, other, comparer));
 }