java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
org.mortbay.util.SingletonList
- All Implemented Interfaces:
- java.util.Collection, java.lang.Iterable, java.util.List
- public class SingletonList
- extends java.util.AbstractList
Singleton List.
This simple efficient implementation of a List with a single
element is provided for JDK 1.2 JVMs, which do not provide
the Collections.singletonList method.
- Version:
- $Revision: 1.2 $
| Methods inherited from class java.util.AbstractList |
add, add, addAll, clear, equals, hashCode, indexOf, lastIndexOf, remove, removeRange, set, subList |
o
private java.lang.Object o
SingletonList
private SingletonList(java.lang.Object o)
newSingletonList
public static SingletonList newSingletonList(java.lang.Object o)
get
public java.lang.Object get(int i)
- Description copied from class:
java.util.AbstractList
- Returns the elements at the specified position in the list.
size
public int size()
- Description copied from interface:
java.util.List
- Get the number of elements in this list. If the list contains more
than Integer.MAX_VALUE elements, return Integer.MAX_VALUE.
listIterator
public java.util.ListIterator listIterator()
- Description copied from class:
java.util.AbstractList
- Obtain a ListIterator over this list, starting at the beginning. This
implementation returns listIterator(0).
listIterator
public java.util.ListIterator listIterator(int i)
- Description copied from class:
java.util.AbstractList
- Obtain a ListIterator over this list, starting at a given position.
A first call to next() would return the same as get(index), and a
first call to previous() would return the same as get(index - 1).
This implementation uses size(), get(int), set(int, Object),
add(int, Object), and remove(int) of the backing list, and does not
support remove, set, or add unless the list does. This implementation
is fail-fast if you correctly maintain modCount.
iterator
public java.util.Iterator iterator()
- Description copied from class:
java.util.AbstractList
- Obtain an Iterator over this list, whose sequence is the list order.
This implementation uses size(), get(int), and remove(int) of the
backing list, and does not support remove unless the list does. This
implementation is fail-fast if you correctly maintain modCount.
Also, this implementation is specified by Sun to be distinct from
listIterator, although you could easily implement it as
return listIterator(0).