예제 #1
0
        public void add(iterator <T> tar, int startOfMe, int startOfTar, int num)//从DoubleLinkedList复制并插入元素
        {
            if (!tar.pos.avaluable)
            {
                return;
            }
            int          count = 0;
            iterator <T> tar2  = new iterator <T>(tar + startOfTar);

            if (!pos.avaluable)
            {
                pos = new DoubleLinkedNode(tar2[0]);
                tar2++;
                count++;
            }
            DoubleLinkedNode first = findPotion(pos, startOfMe);

            do
            {
                if (count >= num)
                {
                    break;
                }
                DoubleLinkedNode now = new DoubleLinkedNode(tar2[0], first, first.Next);
                tar2++;
                count++;
                first = now;
            } while (!tar2.Equal(tar + startOfTar));
        }
예제 #2
0
        public static iterator <T> operator -(iterator <T> a, int id)
        {
            iterator <T> b = new iterator <T>();

            b.pos = findPotion(a.pos, -id);
            return(b);
        }
예제 #3
0
 public bool Equal(iterator <T> it)
 {
     if (pos == it.pos)
     {
         return(true);
     }
     return(false);
 }
예제 #4
0
 public mat(int line,int row)
 {
     baseLine = new lineNode();
     baseLine.lineId = -1;
     it = new iterator();
     it.preline = baseLine;
     it.line = null;
     it.row = null;
     it.prerow = null;
     lineCount = line;
     rowCount = row;
 }
예제 #5
0
 public mat(int[][] tar)
 {
     baseLine = new lineNode();
     baseLine.lineId = -1;
     it = new iterator();
     it.preline = baseLine;
     it.line = null;
     it.row = null;
     it.prerow = null;
     for (int i = 0; i < tar.Length; i++)
         for (int j = 0; j < tar[i].Length; j++)
             set(i, j, tar[i][j]);
 }
예제 #6
0
        public iterator <T> reverseFind(T tar, int start = 0)//从右到左查找元素
        {
            iterator <T> target = this + start;

            do
            {
                if (target[0].CompareTo(tar) == 0)
                {
                    break;
                }
                target--;
            } while (target != this + start);
            return(target);
        }
예제 #7
0
        public iterator <T> find(T tar, int start = 0)//从左到右查找元素
        {
            iterator <T> target = this + start;

            do
            {
                if (target[0].CompareTo(tar) == 0)
                {
                    break;
                }
                target++;
            } while (target != this + start);
            return(target);
        }
예제 #8
0
        public iterator <T> find(T tar, int start, int end)//从左到右查找元素
        {
            iterator <T> target = this + start;
            iterator <T> ending = this + end;

            do
            {
                if (target[0].CompareTo(tar) == 0)
                {
                    break;
                }
                target++;
            } while (target != ending);
            return(target);
        }
예제 #9
0
        public iterator <T> sub(int start = 0)
        {
            DoubleLinkedNode now = findPotion(pos, start);
            iterator <T>     it  = new iterator <T>();

            it.pos = new DoubleLinkedNode(now);
            DoubleLinkedNode next = it.pos;

            do
            {
                now = now.Next;
                new DoubleLinkedNode(now, next, it.pos);
                next = next.Next;
            } while (now != pos.Last);
            return(it);
        }
예제 #10
0
        public void add(iterator <T> tar)//从DoubleLinkedList复制并插入元素
        {
            if (!tar.pos.avaluable)
            {
                return;
            }
            iterator <T> tar2 = new iterator <T>(tar);

            if (!pos.avaluable)
            {
                pos = new DoubleLinkedNode(tar2[0]);
                tar2++;
            }
            DoubleLinkedNode first = pos.Last;

            do
            {
                DoubleLinkedNode now = new DoubleLinkedNode(tar2[0], first, first.Next);
                tar2++;
                first = now;
            } while (!tar2.Equal(tar));
        }
예제 #11
0
 public mat(mat tar)
 {
     baseLine = new lineNode();
     baseLine.lineId = -1;
     it = new iterator();
     it.preline = baseLine;
     it.line = null;
     it.row = null;
     it.prerow = null;
     tar.reLine();
     lineCount = tar.lineCount;
     rowCount = tar.rowCount;
     while (tar.it.line!=null)
     {
         while (tar.it.row != null)
         {
             set(tar.it.line.lineId, tar.it.row.rowId, tar.it.row.value);
             tar.it.nextRow();
         }
         tar.it.nextLine();
     }
 }
예제 #12
0
 private void reQuickSort(iterator <T> s, iterator <T> e)
 {
     if (s - 1 != e && s != e)
     {
         iterator <T> i, j;
         T            x1, x2;
         i  = s;
         j  = e;
         x1 = i[0];
         x2 = i[0];
         while (i != j)
         {
             while (i != j && j[0].CompareTo(x1) < 0)
             {
                 j--;
             }
             if (i != j)
             {
                 i[0] = j[0];
                 i++;
             }
             while (i != j && i[0].CompareTo(x1) > 0)
             {
                 i++;
             }
             if (i != j)
             {
                 j[0] = i[0];
                 j--;
             }
         }
         i[0] = x2;
         reQuickSort(s, i - 1);
         reQuickSort(i + 1, e);
     }
 }
예제 #13
0
 public iterator(iterator <T> it, int id = 0)
 {
     pos = findPotion(pos, id);
 }