|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractCollection<E>
java.util.AbstractList
danbikel.util.AbstractFixedSizeList
danbikel.util.FixedSizeSingletonList
public class FixedSizeSingletonList
A FixedSizeList
implementation for a singleton list (a list with only
one element).
Field Summary | |
---|---|
protected Object |
obj
|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
FixedSizeSingletonList(Collection c)
Constructs a new fixed-size list containing the element in the specified collection. |
|
FixedSizeSingletonList(int size)
Constructs a new fixed-size list with the specified size. |
Method Summary | |
---|---|
Object |
get(int index)
Returns the sole object in this list. |
int |
hashCode()
Generates a hash code for this list. |
protected void |
initialize(int size)
Initializes this singleton list. |
Object |
set(int index,
Object obj)
Sets the object wrapped by this singleton list. |
boolean |
shift(Object obj)
Shifts the old object wrapped by this list “away” and causes this list to wrap the specified object. |
int |
size()
Returns 1. |
Methods inherited from class danbikel.util.AbstractFixedSizeList |
---|
add, addAll, addAll, equals, removeAll |
Methods inherited from class java.util.AbstractList |
---|
add, clear, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList |
Methods inherited from class java.util.AbstractCollection |
---|
contains, containsAll, isEmpty, remove, retainAll, toArray, toArray, toString |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface danbikel.util.FixedSizeList |
---|
add, clear, remove, remove, retainAll |
Methods inherited from interface java.util.List |
---|
contains, containsAll, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, subList, toArray, toArray |
Field Detail |
---|
protected Object obj
Constructor Detail |
---|
public FixedSizeSingletonList(int size)
size
- the size of the list to create
IllegalArgumentException
- if the specified size is greater than 1public FixedSizeSingletonList(Collection c)
c
- a collection containing at most one element
IllegalArgumentException
- if the specified collection contains more
than one elementMethod Detail |
---|
protected void initialize(int size)
initialize
in class AbstractFixedSizeList
size
- the size of this list (must be 1)
IllegalArgumentException
- if the specified size is greater than 1public int size()
size
in interface Collection
size
in interface List
size
in class AbstractCollection
public Object get(int index)
get
in interface List
get
in class AbstractList
index
- the index of the object to return (ignored)
public Object set(int index, Object obj)
set
in interface List
set
in class AbstractFixedSizeList
index
- the index of the object to wrap (ignored)obj
- the object that this list should wrap
public int hashCode()
AbstractFixedSizeList
get(int)
and size()
methods take constant
time.
hashCode
in interface Collection
hashCode
in interface List
hashCode
in class AbstractFixedSizeList
public boolean shift(Object obj)
set(int, java.lang.Object)
does.
shift
in interface FixedSizeList
shift
in class AbstractFixedSizeList
obj
- the object to shift into this singleton list
true
under all circumstances
|
Parsing Engine | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |