public IntArray(IntArray array) { this.ordered = array.ordered; size = array.size; items = new int[size]; System.Array.Copy(array.items, 0, items, 0, size); }
public void AddAll(IntArray array, int offset, int Length) { if (offset + Length > array.size) { throw new Exception( "offset + Length must be <= size: " + offset + " + " + Length + " <= " + array.size); } AddAll(array.items, offset, Length); }
private bool BatchRemove(IntArray c, bool complement) { int[] data = this.items; int r = 0, w = 0; bool modified = false; try { for (; r < size; r++) { if (c.Contains(data[r]) == complement) { data[w++] = data[r]; } } } finally { if (r != size) { System.Array.Copy((Array)(data), r, (Array)(data), w, size - r); w += size - r; } if (w != size) { for (int i = w; i < size; i++) { data[i] = -1; } size = w; modified = true; } } return modified; }
public bool RemoveAll(IntArray c) { return BatchRemove(c, false); }
public bool RetainAll(IntArray c) { return BatchRemove(c, true); }
public bool Part(IntArray c) { int cc = 0; for (int i = 0; i < c.size; i++) { if (Contains(c.items[i])) { cc++; } } return cc != 0; }
public bool ContainsAll(IntArray c) { for (int i = 0; i < c.size; i++) { if (!Contains(c.items[i])) { return false; } } return true; }
public void AddAll(IntArray array) { AddAll(array, 0, array.size); }