Content (final int index, final Content child) { // Confirm basic sanity of child. checkPreConditions(child, index, true); // Ensure the detail checks out OK too. parent.canContainContent(child, index, true); /* * Do a special case of set() where we don't do a remove() then add() * because that affects the modCount. We want to do a true set(). See * issue #15 */ final Content old = elementData[index]; removeParent(old); child.setParent(parent); elementData[index] = child; // for set method we increment dataModCount, but not modCount // set does not change the structure of the List (size()) incDataModOnly(); return old; }