Beispiel #1
0
        internal override bool IsPartitionedBy(LambdaExpression keySel, object comp, bool isDescending)
        {
            // Match the key selector functions:
            if (!this.IsPartitionedBy(keySel))
            {
                return(false);
            }

            // Check the comparers:
            IComparer <TKey> comp1 = TypeSystem.GetComparer <TKey>(comp);

            if (comp1 == null)
            {
                return(false);
            }
            if (this.m_isDescending != isDescending)
            {
                comp1 = new MinusComparer <TKey>(comp1);
            }
            return(this.m_comparer.Equals(comp1));
        }
Beispiel #2
0
        internal override bool IsSamePartition(PartitionInfo p)
        {
            RangePartition <TKey> p1 = p as RangePartition <TKey>;

            if (p1 == null)
            {
                return(false);
            }

            // Check the keys:
            if (this.Keys == null ||
                p1.Keys == null ||
                this.Keys.Length != p1.Keys.Length)
            {
                return(false);
            }

            IComparer <TKey> comp1 = TypeSystem.GetComparer <TKey>(p1.m_comparer);

            if (comp1 == null)
            {
                return(false);
            }
            if (this.IsDescending != p1.IsDescending)
            {
                comp1 = new MinusComparer <TKey>(comp1);
            }
            for (int i = 0; i < this.Keys.Length; i++)
            {
                if (this.m_comparer.Compare(this.Keys[i], p1.Keys[i]) != 0)
                {
                    return(false);
                }
            }

            // Check the comparers:
            return(this.m_comparer.Equals(p1.m_comparer));
        }