public void cover(SequencedList <T> tar, int startOfMe, int startOfTar, int num)//从SequencedList复制并覆盖元素 { if (startOfMe < 0 && startOfMe >= length) { return; } if (startOfTar < 0 || startOfTar >= tar.getLength) { return; } if (num > tar.getLength - startOfTar) { num = tar.getLength - startOfTar; } int j = 0, i = 0; while (j < num) { if (startOfMe + j >= max - 1) { resize((startOfMe + j) / 128 + 1); } if (startOfMe + j >= length) { length = startOfMe + j + 1; } content[startOfMe + i++] = tar[startOfTar + j++]; } }
public void add(SequencedList <T> tar)//从SequencedList复制并插入元素 { if (tar.getLength == 0) { return; } int i; if (length == 0) { i = 1; pos = new SingleLinkedNode <T>(tar[0]); length++; } else { i = 0; } int num = tar.getLength, startOfTar = 0; SingleLinkedNode <T> first = pos.Last; for (; i < num; i++) { SingleLinkedNode <T> now = new SingleLinkedNode <T>(tar[startOfTar + i], first, first.Next); now.Last.Next = now; first = now; length++; } first.Next.Last = first; }
public void add(SequencedList <T> tar, int startOfMe, int startOfTar, int num)//从SequencedList复制并插入元素 { if (startOfMe < 0 && startOfMe >= length) { return; } if (startOfTar < 0 || startOfTar >= tar.getLength) { return; } if (num > tar.getLength - startOfTar) { num = tar.getLength - startOfTar; } if (length + num >= max - 1) { resize((length + num) / 128 + 1); } length += num; for (int k = startOfMe; k < length - num; k++) { content[k + num] = content[k]; } int i = 0, j = 0; while (j < num) { content[startOfMe + i++] = tar[startOfTar + j++]; } }
public SequencedList(SequencedList <T> tar)//使用SequencedList初始化 { content = new T[(tar.getLength / 128 + 1) * 128]; for (int i = 0; i < tar.getLength; i++) { content[i] = tar[i]; } length = tar.getLength; max = (tar.getLength / 128 + 1) * 128; head = 0; }
public void add(SequencedList <T> tar, int startOfMe, int startOfTar, int num)//从SequencedList复制并插入元素 { if (tar.getLength == 0) { return; } if (startOfTar < 0) { return; } if (num > tar.getLength - startOfTar) { num = tar.getLength - startOfTar; } int i; if (length == 0) { i = 1; pos = new SingleLinkedNode <T>(tar[startOfTar]); length++; } else { i = 0; } SingleLinkedNode <T> first = pos; if (startOfMe >= 0) { for (int j = 0; j < startOfMe; j++) { first = first.Next; } } else { for (int j = 0; j > startOfMe; j--) { first = first.Last; } } for (; i < num; i++) { SingleLinkedNode <T> now = new SingleLinkedNode <T>(tar[startOfTar + i], first, first.Next); now.Last.Next = now; first = now; length++; } first.Next.Last = first; }
public void cover(SequencedList <T> tar)//从SequencedList复制并覆盖元素 { int startOfMe = length, num = tar.getLength, startOfTar = 0; int j = 0, i = 0; while (j < num) { if (startOfMe + j >= max - 1) { resize((startOfMe + j) / 128 + 1); } if (startOfMe + j >= length) { length = startOfMe + j + 1; } content[startOfMe + i++] = tar[startOfTar + j++]; } }
public SingleLinkedList(SequencedList <T> tar)//使用SequencedList初始化 { if (tar.getLength == 0) { return; } SingleLinkedNode <T> first; SingleLinkedNode <T> next; first = new SingleLinkedNode <T>(tar[0]); pos = first; length++; for (int i = 1; i < tar.getLength; i++) { next = new SingleLinkedNode <T>(tar[i], first, pos); first.Last = next; first = next; length++; } }
public void add(SequencedList <T> tar)//从SequencedList复制并插入元素 { int startOfMe = length, num = tar.getLength, startOfTar = 0; if (length + num >= max - 1) { resize((length + num) / 128 + 1); } length += num; for (int k = startOfMe; k < length - num; k++) { content[k + num] = content[k]; } int i = 0, j = 0; while (j < num) { content[startOfMe + i++] = tar[startOfTar + j++]; } }