コード例 #1
0
        // ����: �ϲ������ַ�������
        // parameter:
        //        sourceLeft: Դ�������
        //        sourceRight: Դ�ұ�����
        //        targetLeft: Ŀ���������
        //        targetMiddle: Ŀ���м�����
        //        targetRight: Ŀ���ұ�����
        // �����׳��쳣
        public static void MergeStringArray(ArrayList sourceLeft,
			ArrayList sourceRight,
			List<string> targetLeft,
			List<string> targetMiddle,
			List<string> targetRight)
        {
            int i = 0;
            int j = 0;
            string strLeft;
            string strRight;
            int ret;
            while (true)
            {
                strLeft = null;
                strRight = null;
                if (i >= sourceLeft.Count)
                {
                    i = -1;
                }
                else if (i != -1)
                {
                    try
                    {
                        strLeft = (string)sourceLeft[i];
                    }
                    catch
                    {
                        Exception ex = new Exception("i="+Convert.ToString(i)+"----Count="+Convert.ToString(sourceLeft.Count)+"<br/>");
                        throw(ex);
                    }
                }
                if (j >= sourceRight.Count)
                {
                    j = -1;
                }
                else if (j != -1)
                {
                    try
                    {
                        strRight = (string)sourceRight[j];
                    }
                    catch
                    {
                        Exception ex = new Exception("j="+Convert.ToString(j)+"----Count="+Convert.ToString(sourceLeft.Count)+sourceRight.GetHashCode()+"<br/>");
                        throw(ex);
                    }
                }
                if (i == -1 && j == -1)
                {
                    break;
                }

                if (strLeft == null)
                {
                    ret = 1;
                }
                else if (strRight == null)
                {
                    ret = -1;
                }
                else
                {
                    ret = strLeft.CompareTo(strRight);  //MyCompareTo(oldOneKey); //��CompareTO
                }

                if (ret == 0 && targetMiddle != null)
                {
                    targetMiddle.Add(strLeft);
                    i++;
                    j++;
                }

                if (ret<0)
                {
                    if (targetLeft != null && strLeft != null)
                        targetLeft.Add(strLeft);
                    i++;
                }

                if (ret>0 )
                {
                    if (targetRight != null && strRight != null)
                        targetRight.Add(strRight);
                    j++;
                }
            }
        }