Exemplo n.º 1
0
 bool System.Collections.IStructuralEquatable.Equals(object other, System.Collections.IEqualityComparer comparer)
 {
     if (other == null)
     {
         return(false);
     }
     if (other is FdbTuple <T1, T2> )
     {
         var tuple = (FdbTuple <T1, T2>)other;
         return(comparer.Equals(this.Item1, tuple.Item1) &&
                comparer.Equals(this.Item2, tuple.Item2));
     }
     return(FdbTuple.Equals(this, other, comparer));
 }
        bool System.Collections.IStructuralEquatable.Equals(object?other, System.Collections.IEqualityComparer comparer)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }
            if (other == null)
            {
                return(false);
            }

            if (other is PrefixedTuple linked)
            {
                // 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(TupleHelpers.Equals(this, other, comparer));
        }
        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 FdbLinkedTuple <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(FdbTuple.Equals(this, other, comparer));
        }
Exemplo n.º 4
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 tuple = other as IVarTuple;

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

                using (var iter = tuple.GetEnumerator())
                {
                    foreach (var item in this.Head)
                    {
                        if (!iter.MoveNext() || !comparer.Equals(item, iter.Current))
                        {
                            return(false);
                        }
                    }
                    foreach (var item in this.Tail)
                    {
                        if (!iter.MoveNext() || !comparer.Equals(item, iter.Current))
                        {
                            return(false);
                        }
                    }
                    return(!iter.MoveNext());
                }
            }

            return(false);
        }
Exemplo n.º 5
0
 public override bool Equals(object other, System.Collections.IEqualityComparer comparer)
 {
     if (other == null)
     {
         return(false);
     }
     if (other is Right <TLeft, TRight> )
     {
         var right = (Right <TLeft, TRight>)other;
         return(comparer.Equals(this.value, right.value));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 6
0
Arquivo: Maybe.cs Projeto: forki/Funcy
 public override bool Equals(object other, System.Collections.IEqualityComparer comparer)
 {
     if (other == null)
     {
         return(false);
     }
     if (other is None <T> )
     {
         var none = (None <T>)other;
         return(comparer.Equals(this.GetType().DeclaringType, none.GetType().DeclaringType));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 7
0
Arquivo: Maybe.cs Projeto: forki/Funcy
 public override bool Equals(object obj, System.Collections.IEqualityComparer comparer)
 {
     if (obj == null)
     {
         return(false);
     }
     if (obj is Some <T> )
     {
         var other = (Some <T>)obj;
         return(comparer.Equals(this.value, other.value));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 8
0
 public override bool Equals(object obj, System.Collections.IEqualityComparer comparer)
 {
     if (obj == null)
     {
         return(false);
     }
     if (obj is Nil <T> )
     {
         var nil = (Nil <T>)obj;
         return(comparer.Equals(this.GetType().DeclaringType, nil.GetType().DeclaringType));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 9
0
 public override bool Equals(object obj, System.Collections.IEqualityComparer comparer)
 {
     if (obj == null)
     {
         return(false);
     }
     if (obj is Cons <T> )
     {
         var other = (Cons <T>)obj;
         return(comparer.Equals(this.head, other.head) && this.tail.Equals(other.tail, comparer));
     }
     else
     {
         return(false);
     }
 }