List to fix the size preventing add/remove.
The add, remove, clear and retain operations are unsupported. The set method is allowed (as it doesn't change the list size).
Note
Modifying the decorated list directly would results in influencing the outcome of method calls on this object. For example, the bounds of this list would reflect a newly added object to the underlying list.
This class is Serializable from Commons Collections 3.1.
| Modifier and Type | Class and Description |
|---|---|
| private class | FixedSizeList.FixedSizeListIterator
List iterator that only permits changes via set() |
| Modifier and Type | Field and Description |
|---|---|
| private static final long | serialVersionUID
Hides org. |
| Access | Constructor and Description |
|---|---|
| protected | FixedSizeList(final List<E>
the list to decorate, must not be null list)Constructor that wraps (not copies). |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | add(final E
element whose presence in this collection is to be ensured object)Overrides org. Implements java. |
| public void | add(final int
index at which the specified element is to be inserted index, final E element to be inserted object)Overrides org. Implements java. |
| public boolean | addAll(final Collection<? extends E>
collection containing elements to be added to this collection coll)Overrides org. Implements java. |
| public boolean | addAll(final int
index at which to insert the first element from the
specified collection index, final Collection<? extends E> collection containing elements to be added to this list coll)Overrides org. Implements java. |
| public void | clear()
Overrides org. Implements java. |
| public static < the type of the elements in the list E> FixedSizeList | Returns: a new fixed size listthe list to decorate, must not be null list)Factory method to create a fixed size list. |
| public E | get(final int
index of the element to return index)Overrides org. Implements java. |
| public int | indexOf(final Object
element to search for object)Overrides org. Implements java. |
| public boolean | isFull()
Implements org. |
| public Iterator | iterator()
Overrides org. Implements java. |
| public int | lastIndexOf(final Object
element to search for object)Overrides org. Implements java. |
| public ListIterator | listIterator()
Overrides org. Implements java. |
| public ListIterator | listIterator(final int
index of the first element to be returned from the
list iterator (by a call to index)next)Overrides org. Implements java. |
| public int | maxSize()
Implements org. |
| public E | remove(final int
the index of the element to be removed index)Overrides org. Implements java. |
| public boolean | remove(final Object
element to be removed from this collection, if present object)Overrides org. Implements java. |
| public boolean | removeAll(final Collection<?>
collection containing elements to be removed from this collection coll)Overrides org. Implements java. |
| public boolean | removeIf(Predicate<? super E>
a predicate which returns filter)true for elements to be
removedOverrides org. Overrides default java. |
| public boolean | retainAll(final Collection<?>
collection containing elements to be retained in this collection coll)Overrides org. Implements java. |
| public E | set(final int
index of the element to replace index, final E element to be stored at the specified position object)Overrides org. Implements java. |
| public List | subList(final int
low endpoint (inclusive) of the subList fromIndex, final int high endpoint (exclusive) of the subList toIndex)Overrides org. Implements java. fromIndex, inclusive, and toIndex, exclusive.
|
| private static UnsupportedOperationException |
| serialVersionUID | back to summary |
|---|---|
| private static final long serialVersionUID Hides org. Serialization version | |
| FixedSizeList | back to summary |
|---|---|
| protected FixedSizeList(final List<E> list) Constructor that wraps (not copies).
| |
| add | back to summary |
|---|---|
| public boolean add(final E object) Overrides org. Implements java. Doc from java. Ensures that this collection contains the specified element (optional
operation). Returns
Collections that support this operation may place limitations on what
elements may be added to this collection. In particular, some
collections will refuse to add
If a collection refuses to add a particular element for any reason
other than that it already contains the element, it must throw
an exception (rather than returning
| |
| add | back to summary |
|---|---|
| public void add(final int index, final E object) Overrides org. Implements java. Doc from java. 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).
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(final Collection<? extends E> coll) Overrides org. Implements java. Doc from java. Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.) If the specified collection has a defined encounter order, processing of its elements generally occurs in that order.
| |
| addAll | back to summary |
|---|---|
| public boolean addAll(final int index, final Collection<? extends E> coll) Overrides org. Implements java. Doc from java. Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
| |
| clear | back to summary |
|---|---|
| public void clear() Overrides org. Implements java. Doc from java. Removes all of the elements from this collection (optional operation). The collection will be empty after this method returns.
| |
| fixedSizeList | back to summary |
|---|---|
| public static <E> FixedSizeList Factory method to create a fixed size list.
| |
| get | back to summary |
|---|---|
| public E get(final int index) Overrides org. Implements java. Doc from java. Returns the element at the specified position in this list.
| |
| indexOf | back to summary |
|---|---|
| public int indexOf(final Object object) Overrides org. Implements java. Doc from java. Returns the index of the first occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the lowest index | |
| isFull | back to summary |
|---|---|
| public boolean isFull() Implements org. Doc from org. Returns true if this collection is full and no new elements can be added.
| |
| iterator | back to summary |
|---|---|
| public Iterator Overrides org. Implements java. Doc from java. Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee). | |
| lastIndexOf | back to summary |
|---|---|
| public int lastIndexOf(final Object object) Overrides org. Implements java. Doc from java. Returns the index of the last occurrence of the specified element
in this list, or -1 if this list does not contain the element.
More formally, returns the highest index | |
| listIterator | back to summary |
|---|---|
| public ListIterator Overrides org. Implements java. Doc from java. Returns a list iterator over the elements in this list (in proper sequence).
| |
| listIterator | back to summary |
|---|---|
| public ListIterator Overrides org. Implements java. Doc from java. Returns a list iterator over the elements in this list (in proper
sequence), starting at the specified position in the list.
The specified index indicates the first element that would be
returned by an initial call to
| |
| maxSize | back to summary |
|---|---|
| public int maxSize() Implements org. Doc from org. Gets the maximum size of the collection (the bound).
| |
| remove | back to summary |
|---|---|
| public E remove(final int index) Overrides org. Implements java. Doc from java. 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.
| |
| remove | back to summary |
|---|---|
| public boolean remove(final Object object) Overrides org. Implements java. Doc from java. Removes a single instance of the specified element from this
collection, if it is present (optional operation). More formally,
removes an element | |
| removeAll | back to summary |
|---|---|
| public boolean removeAll(final Collection<?> coll) Overrides org. Implements java. Doc from java. Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.
| |
| removeIf | back to summary |
|---|---|
| public boolean removeIf(Predicate<? super E> filter) Overrides org. Overrides default java. Doc from java. Removes all of the elements of this collection that satisfy the given predicate. Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller. | |
| retainAll | back to summary |
|---|---|
| public boolean retainAll(final Collection<?> coll) Overrides org. Implements java. Doc from java. Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.
| |
| set | back to summary |
|---|---|
| public E set(final int index, final E object) Overrides org. Implements java. Doc from java. Replaces the element at the specified position in this list with the specified element (optional operation).
| |
| subList | back to summary |
|---|---|
| public List Overrides org. Implements java. Doc from java. Returns a view of the portion of this list between the specified
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
Similar idioms may be constructed for indexOf and
lastIndexOf, and all of the algorithms in the
Collections class can be applied to a subList.The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.) | |
| unsupportedOperationException | back to summary |
|---|---|
| private static UnsupportedOperationException unsupportedOperationException() | |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| public void | add(final Object
the element to insert object)Overrides org. Implements java. |
| public void | remove()
Overrides org. Implements java. next or previous (optional operation).
|
| FixedSizeListIterator | back to summary |
|---|---|
| protected FixedSizeListIterator(final ListIterator<E> iterator) | |
| add | back to summary |
|---|---|
| public void add(final Object object) Overrides org. Implements java. Doc from org. Inserts the specified element into the list (optional operation).
The element is inserted immediately before the element that
would be returned by
| |
| remove | back to summary |
|---|---|
| public void remove() Overrides org. Implements java. Doc from org. Removes from the list the last element that was returned by
| |