public static void addNew(Vector to, Vector all) { synchronized (to) { for (int i = 0; i < all.size(); ++i) { if (0 <= Util.getIndex(to, all.elementAt(i))) continue; to.addElement(all.elementAt(i)); } } }
public static void removeAll(Vector to, Vector all) { synchronized (to) { int current = 0; for (int index = 0; index < to.size(); ++index) { if (0 <= Util.getIndex(all, to.elementAt(index))) continue; if (current < index) { to.setElementAt(to.elementAt(index), current); current++; } } if (current < to.size()) to.setSize(current); } }
public static void addAll(Vector to, Vector all) { synchronized (to) { for (int i = 0; i < all.size(); ++i) { to.addElement(all.elementAt(i)); } } }
public static void sort(Vector subnodes) { for (int i = 1; i < subnodes.size(); ++i) { Sortable currNode = (Sortable) subnodes.elementAt(i); int j = i - 1; for (; j >= 0; --j) { Sortable itemJ = (Sortable) subnodes.elementAt(j); if (compareNodes(itemJ, currNode) <= 0) { break; } subnodes.setElementAt(itemJ, j + 1); } if (j + 1 != i) { subnodes.setElementAt(currNode, j + 1); } } }
public static int getIndex(Vector v, Object o) { synchronized (v) { int size = v.size(); for (int i = 0; i < size; ++i) { if (v.elementAt(i) == o) { return i; } } } return -1; }