int[] (Collection<? extends T> items) { int[] indices = new int[items.size()]; int i = 0; for (T item : items) { int newIndex = add(item); for (int j = 0; j < i; j++) { if (indices[j] >= newIndex) indices[j]++; } indices[i] = newIndex; i++; } return indices; }