Example #1
0
        internal static void MergeItemLists(ref List<ResultItem> list1, List<ResultItem> list2, int maxMergeCount, BaseComparer baseComparer)
        {
            int mergedListCount = list1.Count + list2.Count;
            int count1 = 0;
            int count2 = 0;
            if (mergedListCount > maxMergeCount)
            {
                mergedListCount = maxMergeCount;
            }
            List<ResultItem> newList = new List<ResultItem>(mergedListCount);

            #region Merge until one list ends
            for (int i = 0; i < mergedListCount && count1 != list1.Count && count2 != list2.Count; i++)
            {
                newList.Add((baseComparer.Compare(list1[count1], list2[count2]) <= 0) ?
                                    list1[count1++] : // list1 item is greater
                                    list2[count2++]); // list2 item is greater
            }
            #endregion

            #region Append rest of the list1/list2 to newList
            if (count1 != list1.Count && newList.Count < mergedListCount)
            {
                int count = list1.Count - count1;
                for (int i = 0; i < count && newList.Count < mergedListCount; i++)
                {
                    newList.Add(list1[count1++]);
                }
            }
            else if (count2 != list2.Count && newList.Count < mergedListCount)
            {
                int count = list2.Count - count2;
                for (int i = 0; i < count && newList.Count < mergedListCount; i++)
                {
                    newList.Add(list2[count2++]);
                }
            }
            #endregion

            #region Update reference
            list1 = newList;
            #endregion
        }
Example #2
0
		protected static void CreateGroupedChildren(IndexList list,BaseComparer sc)
		{
			list.Add(sc);
		}
Example #3
0
		protected GroupComparer CreateGroupHeader (BaseComparer sc)
		{
			GroupComparer gc = new GroupComparer(sc.ColumnCollection,sc.ListIndex,sc.ObjectArray);
			IndexList.Add(gc);
			return gc;
		}
Example #4
0
		static string ExtractValue(BaseComparer element)
		{
			string val = String.Empty;
			GroupColumn gc = element.ColumnCollection[0] as GroupColumn;
			if (gc !=  null) {
				val = element.ObjectArray[0].ToString();
			}
			return val;
		}
Example #5
0
        /// <summary>
        /// Applies the Condition on the specified item value.
        /// </summary>
        /// <param name="itemValue">The item value.</param>
        /// <returns></returns>
        internal bool Process(byte[] itemValue)
        {
            bool retVal = false;
            BaseComparer itemComparer = new BaseComparer(false, null, new List<SortOrder>(1) { new SortOrder(DataType, SortBy.ASC) });

            switch (Operation)
            {
                case Operation.Equals:
                    retVal = (ByteArrayComparerUtil.CompareByteArrays(Value, itemValue)) ? true : false;
                    break;

                case Operation.NotEquals:
                    retVal = (!ByteArrayComparerUtil.CompareByteArrays(Value, itemValue)) ? true : false;
                    break;

                case Operation.GreaterThan:
                    retVal = (itemComparer.Compare(Value, itemValue) < 0) ? true : false;
                    break;

                case Operation.GreaterThanEquals:
                    retVal = (itemComparer.Compare(Value, itemValue) <= 0) ? true : false;
                    break;

                case Operation.LessThan:
                    retVal = (itemComparer.Compare(Value, itemValue) > 0) ? true : false;
                    break;

                case Operation.LessThanEquals:
                    retVal = (itemComparer.Compare(Value, itemValue) >= 0) ? true : false;
                    break;

                case Operation.BitwiseComplement:
                case Operation.BitwiseAND:
                case Operation.BitwiseOR:
                case Operation.BitwiseXOR:
                case Operation.BitwiseShiftLeft:
                case Operation.BitwiseShiftRight:
                    retVal = CheckBitwiseCondition(itemValue);
                    break;
            }
            return retVal;
        }