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)); }
public static iterator <T> operator -(iterator <T> a, int id) { iterator <T> b = new iterator <T>(); b.pos = findPotion(a.pos, -id); return(b); }
public bool Equal(iterator <T> it) { if (pos == it.pos) { return(true); } return(false); }
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; }
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]); }
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); }
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); }
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); }
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); }
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)); }
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(); } }
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); } }
public iterator(iterator <T> it, int id = 0) { pos = findPotion(pos, id); }