int (T item) { int index; if (myComparator != null) { index = Collections.binarySearch(myItems, item, myComparator); } else { index = myItems.size(); } index = index >= 0 ? index : -(index + 1); add(index, item); return index; }