|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.walend.collection.AbstractArrayList
An implementation of List backed by an array.
This class implements the net.walend.collection.List interface, based very heavily on the java.util.ArrayList class by Josh Bloch. Any mistakes I'm sure are my own and not his.
Nested Class Summary | |
protected class |
AbstractArrayList.ListItr
|
Field Summary | |
private java.lang.Object[] |
elementData
The array buffer into which the elements of the ArrayList are stored. |
private Identitor |
identitor
|
protected int |
modCount
The number of times this list has been structurally modified. |
private int |
size
The size of the ArrayList (the number of elements it contains). |
Fields inherited from interface net.walend.collection.List |
EMPTY |
Constructor Summary | |
protected |
AbstractArrayList()
|
protected |
AbstractArrayList(Collection collection)
|
protected |
AbstractArrayList(java.util.Collection collection)
|
protected |
AbstractArrayList(Identitor ident)
|
protected |
AbstractArrayList(Identitor ident,
int initialCapacity)
|
protected |
AbstractArrayList(int initialCapacity)
|
Method Summary | |
protected boolean |
add(int index,
java.lang.Object ob)
Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). |
protected boolean |
add(java.lang.Object object)
Adds a Object to the MutableCollection. |
protected boolean |
addAll(Collection c)
Adds all the Objects in c to this MutableCollection by using the add() method. |
protected boolean |
addAll(int index,
Collection col)
Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation). |
protected void |
checkRange(int index)
|
protected void |
checkRangeForAdd(int index)
|
protected void |
clear()
Removes all of the Objects in this collection. |
boolean |
contains(java.lang.Object object)
Returns true if this collection contains the specified Object. |
boolean |
containsAll(Collection c)
Returns true if this collection contains all of the Objects in the specified collection. |
protected void |
ensureCapacity(int minCapacity)
Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
java.lang.Object |
get(int index)
Return the object at position index. |
Identitor |
getIdentitor()
Returns the Identitor for this Collection. |
java.util.Collection |
getJavaCollection()
Return a java.util.Collection of these Objects. |
java.util.List |
getJavaList()
Return a java.util.Collection of these Objects. |
java.lang.Class |
getPrincipleInterface()
Returns the class's principle interface for state comparisons. |
int |
indexOf(java.lang.Object ob)
Returns the index of the first occurrence of ob, or -1 if ob is not in the list. |
int |
indexOfSubList(List subList)
Returns the index of the subList if this List contains the subList starting at any index, or -1. |
boolean |
isEmpty()
Returns true if this collection contains no elements. |
java.util.Iterator |
iterator()
Returns an iterator over the Objects in this collection. |
int |
lastIndexOf(java.lang.Object ob)
Returns the index of the last occurrence of ob, or -1 if ob is not in the list. |
java.util.ListIterator |
listIterator()
Returns an Iterator over this list that iterates through the list in order. |
java.util.ListIterator |
listIterator(int start)
Returns an Iterator over this list that iterates through the list in order, starting with the Object at index start. |
protected java.lang.Object |
remove(int index)
Removes and returns the object at index in this list. |
protected boolean |
remove(java.lang.Object object)
Removes a Object from the MutableCollection. |
protected boolean |
removeAll(Collection c)
Removes all the Objects in c from this MutableCollection by using the remove() method. |
protected boolean |
retainAll(Collection c)
Retains only the Objects in this collection that are contained in c by using the contains() and remove() methods. |
boolean |
sameContentsAs(Collection c)
Returns true if this Collection's contents are equal to c's. |
boolean |
sameListAs(List list)
Returns true if this contains the same objects in the same order as list. |
boolean |
sameStateAs(HasState victem)
If two HasStates have the same internal state, return true. |
protected java.lang.Object |
set(int index,
java.lang.Object ob)
Replaces the element at the specified position in this list with the specified element |
int |
size()
Returns the number of elements in this collection. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
private Identitor identitor
private transient java.lang.Object[] elementData
private int size
protected transient int modCount
This field is used by the iterator and list iterator implementation returned by the iterator and listIterator methods. If the value of this field changes unexpectedly, the iterator (or list iterator) will throw a ConcurrentModificationException in response to the next, remove, previous, set or add operations. This provides fail-fast behavior, rather than non-deterministic behavior in the face of concurrent modification during iteration.
Use of this field by subclasses is optional. If a subclass wishes to provide fail-fast iterators (and list iterators), then it merely has to increment this field in its add(int, Object) and remove(int) methods (and any other methods that it overrides that result in structural modifications to the list). A single call to add(int, Object) or remove(int) must add no more than one to this field, or the iterators (and list iterators) will throw bogus ConcurrentModificationExceptions. If an implementation does not wish to provide fail-fast iterators, this field may be ignored.
Constructor Detail |
protected AbstractArrayList()
protected AbstractArrayList(int initialCapacity)
protected AbstractArrayList(Collection collection)
protected AbstractArrayList(java.util.Collection collection)
protected AbstractArrayList(Identitor ident)
protected AbstractArrayList(Identitor ident, int initialCapacity)
Method Detail |
public Identitor getIdentitor()
getIdentitor
in interface Collection
public int size()
size
in interface Collection
public boolean isEmpty()
isEmpty
in interface Collection
public boolean contains(java.lang.Object object)
contains
in interface Collection
public java.util.Iterator iterator()
iterator
in interface Collection
public boolean containsAll(Collection c)
containsAll
in interface Collection
public boolean sameContentsAs(Collection c)
sameContentsAs
in interface Collection
public java.util.Collection getJavaCollection()
getJavaCollection
in interface Collection
protected void checkRange(int index)
protected void checkRangeForAdd(int index)
public java.lang.Object get(int index)
get
in interface List
java.lang.IndexOutOfBoundsException
- if the index is not in the list.public int indexOf(java.lang.Object ob)
indexOf
in interface List
public int lastIndexOf(java.lang.Object ob)
lastIndexOf
in interface List
public java.util.ListIterator listIterator()
listIterator
in interface List
public java.util.ListIterator listIterator(int start)
listIterator
in interface List
java.lang.IndexOutOfBoundsException
- if the index is not in the list.public int indexOfSubList(List subList)
indexOfSubList
in interface List
public boolean sameListAs(List list)
sameListAs
in interface List
public java.util.List getJavaList()
getJavaList
in interface List
protected void ensureCapacity(int minCapacity)
minCapacity
- the desired minimum capacity.protected boolean add(java.lang.Object object)
protected boolean remove(java.lang.Object object)
protected boolean addAll(Collection c)
protected boolean removeAll(Collection c)
protected boolean retainAll(Collection c)
protected void clear()
protected boolean add(int index, java.lang.Object ob)
java.lang.IndexOutOfBoundsException
- if the index is not in the list.protected boolean addAll(int index, Collection col)
java.lang.IndexOutOfBoundsException
- if the index is not in the list.protected java.lang.Object remove(int index)
java.lang.IndexOutOfBoundsException
- if the index is not in the list.protected java.lang.Object set(int index, java.lang.Object ob)
java.lang.IndexOutOfBoundsException
- if the index is not in the list.public java.lang.Class getPrincipleInterface()
HasState
getPrincipleInterface
in interface HasState
public boolean sameStateAs(HasState victem)
HasState
For objects with subobjects, Generally this method should only return true if the internal objects are equal. Implement a contentsHaveSameState() method to determine if the contents have the same state.
sameStateAs
in interface HasState
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |