| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 | using System;using System.Collections.Generic;namespace PaintDotNet{    [Serializable]    public struct Triple<T, U, V>    {        private T first;        private U second;        private V third;        public T First        {            get            {                return this.first;            }        }        public U Second        {            get            {                return this.second;            }        }        public V Third        {            get            {                return this.third;            }        }        public override int GetHashCode()        {            int firstHash;            int secondHash;            int thirdHash;            if (object.ReferenceEquals(this.first, null))            {                firstHash = 0;            }            else            {                firstHash = this.first.GetHashCode();            }            if (object.ReferenceEquals(this.second, null))            {                secondHash = 0;            }            else            {                secondHash = this.second.GetHashCode();            }            if (object.ReferenceEquals(this.third, null))            {                thirdHash = 0;            }            else            {                thirdHash = this.third.GetHashCode();            }            return firstHash ^ secondHash ^ thirdHash;        }        public override bool Equals(object obj)        {            return ((obj != null) && (obj is Triple<T, U, V>) && (this == (Triple<T, U, V>)obj));        }        public static bool operator ==(Triple<T, U, V> lhs, Triple<T, U, V> rhs)        {            bool firstEqual;            bool secondEqual;            bool thirdEqual;            if (object.ReferenceEquals(lhs.First, null) && object.ReferenceEquals(rhs.First, null))            {                firstEqual = true;            }            else if (object.ReferenceEquals(lhs.First, null) || object.ReferenceEquals(rhs.First, null))            {                firstEqual = false;            }            else            {                firstEqual = lhs.First.Equals(rhs.First);            }            if (object.ReferenceEquals(lhs.Second, null) && object.ReferenceEquals(rhs.Second, null))            {                secondEqual = true;            }            else if (object.ReferenceEquals(lhs.Second, null) || object.ReferenceEquals(rhs.Second, null))            {                secondEqual = false;            }            else            {                secondEqual = lhs.Second.Equals(rhs.Second);            }            if (object.ReferenceEquals(lhs.Third, null) && object.ReferenceEquals(rhs.Third, null))            {                thirdEqual = true;            }            else if (object.ReferenceEquals(lhs.Third, null) || object.ReferenceEquals(rhs.Third, null))            {                thirdEqual = false;            }            else            {                thirdEqual = lhs.Third.Equals(rhs.Third);            }            return firstEqual && secondEqual && thirdEqual;        }        public static bool operator !=(Triple<T, U, V> lhs, Triple<T, U, V> rhs)        {            return !(lhs == rhs);        }        public Triple(T first, U second, V third)        {            this.first = first;            this.second = second;            this.third = third;        }        private sealed class TripleComparer            : IEqualityComparer<Triple<T, U, V>>        {            private IEqualityComparer<T> tComparer;            private IEqualityComparer<U> uComparer;            private IEqualityComparer<V> vComparer;            public TripleComparer(IEqualityComparer<T> tComparer, IEqualityComparer<U> uComparer, IEqualityComparer<V> vComparer)            {                this.tComparer = tComparer;                this.uComparer = uComparer;                this.vComparer = vComparer;            }            public bool Equals(Triple<T, U, V> x, Triple<T, U, V> y)            {                return this.tComparer.Equals(x.First, y.First) && this.uComparer.Equals(x.Second, y.Second) && this.vComparer.Equals(x.Third, y.Third);            }            public int GetHashCode(Triple<T, U, V> obj)            {                return this.tComparer.GetHashCode(obj.First) ^ this.uComparer.GetHashCode(obj.Second) ^ this.vComparer.GetHashCode(obj.Third);            }        }        public static IEqualityComparer<Triple<T, U, V>> CreateComparer(            IEqualityComparer<T> tComparer,            IEqualityComparer<U> uComparer,            IEqualityComparer<V> vComparer)        {            return new TripleComparer(                tComparer ?? EqualityComparer<T>.Default,                uComparer ?? EqualityComparer<U>.Default,                vComparer ?? EqualityComparer<V>.Default);        }    }}
 |