示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="t"></param>
        /// <param name="a_ComparisonType"></param>
        /// <returns></returns>
        private bool VerifyOrder(Node t, COMPARISON_TYPE a_ComparisonType)
        {
            // ignore if at bottom
            if (t == m_Bottom)
            {
                return(true);
            }

            try
            {
                if ((t.Left == m_Bottom || CompareTo(t.Data, t.Left.Data, a_ComparisonType) > 0) &&
                    (t.Right == m_Bottom || CompareTo(t.Data, t.Right.Data, a_ComparisonType) <= 0))
                {
                    return(VerifyOrder(t.Left, a_ComparisonType) && VerifyOrder(t.Right, a_ComparisonType));
                }
                else
                {
                    return(false);
                }
            }
            catch (NotImplementedException)
            {
                // If a particular comparison type is not implemented, just assume that was done
                // for a good reason and return true. (Otherwise the user's application will not work anyway)
                return(true);
            }
        }
示例#2
0
        /// <summary>
        /// Takes two arrays and returns which is greater based on byte
        /// (always positive) values.  Note that this (obviously) isn't
        /// a good way to compare serialized integers, etc.
        /// TODO: Null values.
        /// </summary>
        public COMPARISON_TYPE CompareByteArrays(byte[] a1, byte[] a2)
        {
            COMPARISON_TYPE comparisonOutcome = COMPARISON_TYPE.EQUALS;

            if (a1.Length == a2.Length)
            {
                for (int i = 0; i < a1.Length; i++)
                {
                    if (a1[i] != a2[i])
                    {
                        if (a1[i] > a2[i])
                        {
                            comparisonOutcome = COMPARISON_TYPE.GREATER_THAN;
                        }
                        else
                        {
                            comparisonOutcome = COMPARISON_TYPE.LESS_THAN;
                        }
                        break;
                    }
                }
            }

            return(comparisonOutcome);
        }
示例#3
0
        public Comparison(string strOperator, Column relatedColumn, byte[] abytValue)
        {
            COMPARISON_TYPE type = COMPARISON_TYPE.EQUALS;

            switch (strOperator)
            {
            case "=":
                type = COMPARISON_TYPE.EQUALS;
                break;

            case "<":
                type = COMPARISON_TYPE.LESS_THAN;
                break;

            case ">":
                type = COMPARISON_TYPE.GREATER_THAN;
                break;

            case "like":
            case "LIKE":
                throw new NotImplementedException("LIKE comparison not yet implemented.");

            default:
                throw new Exception("Illegal comparison type: " + strOperator);
            }

            _init(type, relatedColumn, abytValue);
        }
示例#4
0
        private void _init(COMPARISON_TYPE type, Column relatedColumn, byte[] abytValue)
        {
            this.comparisonType = type;
            //this.strColumnName = strColName;
            this.colRelated          = relatedColumn;
            this.abytComparisonValue = abytValue;

            this.objParsedValue = Router.routeMe(this.colRelated).toNative(abytValue);
        }
示例#5
0
 /// <summary>
 /// Check if two values are equal.
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <param name="a_ComparisonType"></param>
 /// <returns></returns>
 protected virtual bool IsEqual(T a, T b, COMPARISON_TYPE a_ComparisonType)
 {
     return(a.Equals(b));
 }
示例#6
0
 /// <summary>
 /// Compare two values to each other.
 /// </summary>
 /// <param name="a"></param>
 /// <param name="b"></param>
 /// <param name="a_ComparisonType"></param>
 /// <returns></returns>
 protected virtual int CompareTo(T a, T b, COMPARISON_TYPE a_ComparisonType)
 {
     return(a.CompareTo(b));
 }
示例#7
0
 public Comparison(COMPARISON_TYPE type, Column relatedColumn, byte[] abytValue)
 {
     _init(type, relatedColumn, abytValue);
 }