public Item setItem(int index, Item item) {
        if (index >= subitems.size() || index < 0)
            throw new IndexOutOfBoundsException("Could not add a subitem at position " + index + " to " + this);

        adding(item);
        Item old = subitems.set(index, item);
        if (old != item)
            removing(old);
        return old;
    }
Replaces the item at the given index.

@param  index the (0-base) index of the item to replace
@param  item the new item
@return the old item at this position. The parent of the old item is <i>not</i> cleared
@throws IndexOutOfBoundsException if there is no item at this index
container-search/src/main/java/com/yahoo/prelude/query/CompositeItem.java