Package com.globalmentor.collections
Class ObjectList<E>
java.lang.Object
com.globalmentor.collections.ObjectList<E>
- Type Parameters:
E
- The type of object contained in the list.
- All Implemented Interfaces:
ImmutableCollection<E>
,Iterable<E>
,Collection<E>
,List<E>
Deprecated.
A read-only list containing a single object.
- Author:
- Garret Wilson
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.Inserts the specified element at the specified position in this list (optional operation).boolean
Deprecated.boolean
addAll
(int index, Collection<? extends E> c) Deprecated.boolean
addAll
(Collection<? extends E> c) Deprecated.void
clear()
Deprecated.boolean
Deprecated.boolean
containsAll
(Collection<?> c) Deprecated.boolean
Deprecated.get
(int index) Deprecated.Returns the element at the specified position in this list.int
hashCode()
Deprecated.int
Deprecated.Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.boolean
isEmpty()
Deprecated.iterator()
Deprecated.int
Deprecated.Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.Deprecated.Returns a list iterator over the elements in this list (in proper sequence).listIterator
(int index) Deprecated.Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.remove
(int index) Deprecated.Removes the element at the specified position in this list (optional operation).boolean
Deprecated.boolean
removeAll
(Collection<?> c) Deprecated.boolean
retainAll
(Collection<?> c) Deprecated.Deprecated.Replaces the element at the specified position in this list with the specified element (optional operation).int
size()
Deprecated.subList
(int fromIndex, int toIndex) Deprecated.Returns a view of the portion of this list between the specifiedfromIndex
, inclusive, andtoIndex
, exclusive.Object[]
toArray()
Deprecated.<T> T[]
toArray
(T[] a) Deprecated.toString()
Deprecated.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream
Methods inherited from interface java.util.List
replaceAll, sort, spliterator
-
Constructor Details
-
ObjectList
Deprecated.Object constructor.- Parameters:
object
- The object to hold in the list.- Throws:
NullPointerException
- if the given object isnull
.
-
-
Method Details
-
size
public int size()Deprecated. -
isEmpty
public boolean isEmpty()Deprecated. -
contains
Deprecated. -
iterator
Deprecated. -
toArray
Deprecated. -
toArray
public <T> T[] toArray(T[] a) Deprecated. -
add
Deprecated. -
remove
Deprecated. -
containsAll
Deprecated.- Specified by:
containsAll
in interfaceCollection<E>
- Specified by:
containsAll
in interfaceList<E>
-
addAll
Deprecated. -
addAll
Deprecated. -
retainAll
Deprecated. -
removeAll
Deprecated. -
clear
public void clear()Deprecated. -
get
Deprecated.Returns the element at the specified position in this list.- Specified by:
get
in interfaceList<E>
- Parameters:
index
- index of the element to return- Returns:
- the element at the specified position in this list
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)
-
set
Deprecated.Replaces the element at the specified position in this list with the specified element (optional operation).- Specified by:
set
in interfaceList<E>
- Parameters:
index
- index of the element to replaceelement
- element to be stored at the specified position- Returns:
- the element previously at the specified position
- Throws:
UnsupportedOperationException
- if theset
operation is not supported by this listClassCastException
- if the class of the specified element prevents it from being added to this listNullPointerException
- if the specified element is null and this list does not permit null elementsIllegalArgumentException
- if some property of the specified element prevents it from being added to this listIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)
-
add
Deprecated.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).- Specified by:
add
in interfaceList<E>
- Parameters:
index
- index at which the specified element is to be insertedelement
- element to be inserted- Throws:
UnsupportedOperationException
- if theadd
operation is not supported by this listClassCastException
- if the class of the specified element prevents it from being added to this listNullPointerException
- if the specified element is null and this list does not permit null elementsIllegalArgumentException
- if some property of the specified element prevents it from being added to this listIndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()
)
-
remove
Deprecated.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.- Specified by:
remove
in interfaceList<E>
- Parameters:
index
- the index of the element to be removed- Returns:
- the element previously at the specified position
- Throws:
UnsupportedOperationException
- if theremove
operation is not supported by this listIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()
)
-
indexOf
Deprecated.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 indexi
such that(o==null ? get(i)==null : o.equals(get(i)))
, or -1 if there is no such index.- Specified by:
indexOf
in interfaceList<E>
- Parameters:
o
- element to search for- Returns:
- the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element
- Throws:
ClassCastException
- if the type of the specified element is incompatible with this list (optional)NullPointerException
- if the specified element is null and this list does not permit null elements (optional)
-
lastIndexOf
Deprecated.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 indexi
such that(o==null ? get(i)==null : o.equals(get(i)))
, or -1 if there is no such index.- Specified by:
lastIndexOf
in interfaceList<E>
- Parameters:
o
- element to search for- Returns:
- the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element
- Throws:
ClassCastException
- if the type of the specified element is incompatible with this list (optional)NullPointerException
- if the specified element is null and this list does not permit null elements (optional)
-
listIterator
Deprecated.Returns a list iterator over the elements in this list (in proper sequence).- Specified by:
listIterator
in interfaceList<E>
- Returns:
- a list iterator over the elements in this list (in proper sequence)
-
listIterator
Deprecated.Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call tonext
. An initial call toprevious
would return the element with the specified index minus one.- Specified by:
listIterator
in interfaceList<E>
- Parameters:
index
- index of first element to be returned from the list iterator (by a call to thenext
method)- Returns:
- a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list
- Throws:
IndexOutOfBoundsException
- if the index is out of range (index < 0 || index > size()
)
-
subList
Deprecated.Returns a view of the portion of this list between the specifiedfromIndex
, inclusive, andtoIndex
, exclusive. (IffromIndex
andtoIndex
are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.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:
list.subList(from, to).clear();
Similar idioms may be constructed forindexOf
andlastIndexOf
, and all of the algorithms in theCollections
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.)
- Specified by:
subList
in interfaceList<E>
- Parameters:
fromIndex
- low endpoint (inclusive) of the subListtoIndex
- high endpoint (exclusive) of the subList- Returns:
- a view of the specified range within this list
- Throws:
IndexOutOfBoundsException
- for an illegal endpoint index value (fromIndex < 0 || toIndex > size || fromIndex > toIndex
)
-
equals
Deprecated. -
hashCode
public int hashCode()Deprecated. -
toString
Deprecated.
-
Collections.singletonList(Object)
.