public E put(int index, E elem) {
    	checkIndexAdd(index);

    	if (index < size()) {
    		return doSet(index, elem);
    	} else {
    		doAdd(-1, elem);
    		return null;
    	}
    }
Sets or adds the element.
If the index is smaller than the size of the list, the existing element is replaced.
If the index equals the size of the list, the element is added.

@param index	index where element will be placed
@param elem	element to put
@return		old element if an element was replaced, null if the element was added
jphp-runtime/src/php/runtime/memory/support/IList.java