/** * Return the size of the list. * * @return The number of elements in the list. */ public int size() { maintain(); return list.size(); }
/** * Inserts the specified element at the specified position in this list * (optional operation). Shifts the element currently at that position * (if any) and any subsequent elements to the right (adds one to their * indices). * * @param index Index at which the specified element is to be inserted. * @param obj Element to be inserted. */ public void add(final int index, final Object obj) { maintain(); SoftObject soft = SoftObject.create(obj, queue); list.add(index, soft); }
/** * Removes the element at the specified position in this list (optional * operation). Shifts any subsequent elements to the left (subtracts one * from their indices). Returns the element that was removed from the list. * * @param index The index of the element to remove. * @return The element previously at the specified position. */ public Object remove(final int index) { maintain(); Object obj = list.remove(index); return Objects.deref(obj); }
/** * Replaces the element at the specified position in this list with the * specified element. * * @param index Index of element to replace. * @param obj Element to be stored at the specified postion. * @return The previous element at the given index. */ public Object set(final int index, final Object obj) { maintain(); SoftObject soft = SoftObject.create(obj, queue); soft = (SoftObject)list.set(index, soft); return Objects.deref(soft); }