|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractCollection<E>
org.terracotta.collections.TerracottaList<E>
public class TerracottaList<E>
TerracottaList is an implementation of List, backed by an array. All optional operations adding, removing,
and replacing are supported. The elements can be any objects.
| Field Summary | |
|---|---|
protected int |
modCount
|
| Constructor Summary | |
|---|---|
TerracottaList()
Constructs a new instance of TerracottaList with ten capacity. |
|
TerracottaList(Collection<? extends E> collection)
Constructs a new instance of TerracottaList containing the elements of the specified collection. |
|
TerracottaList(int capacity)
Constructs a new instance of TerracottaList with the specified capacity. |
|
| Method Summary | ||
|---|---|---|
boolean |
add(E object)
Adds the specified object at the end of this TerracottaList. |
|
void |
add(int location,
E object)
Inserts the specified object into this TerracottaList at the specified location. |
|
boolean |
addAll(Collection<? extends E> collection)
Adds the objects in the specified collection to this TerracottaList. |
|
boolean |
addAll(int location,
Collection<? extends E> collection)
Inserts the objects in the specified collection at the specified location in this List. |
|
void |
clear()
Removes all elements from this TerracottaList, leaving it empty. |
|
Object |
clone()
Returns a new TerracottaList with the same elements, the same size and the same capacity as this TerracottaList. |
|
boolean |
contains(Object object)
Searches this TerracottaList for the specified object. |
|
void |
ensureCapacity(int minimumCapacity)
Ensures that after this operation the TerracottaList can hold the specified number of elements without
further growing. |
|
boolean |
equals(Object object)
Compares the specified object to this list and return true if they are equal. |
|
E |
get(int location)
|
|
int |
hashCode()
Returns the hash code of this list. |
|
int |
indexOf(Object object)
|
|
boolean |
isEmpty()
|
|
Iterator<E> |
iterator()
Returns an iterator on the elements of this list. |
|
int |
lastIndexOf(Object object)
|
|
ListIterator<E> |
listIterator()
Returns a ListIterator on the elements of this list. |
|
ListIterator<E> |
listIterator(int location)
Returns a list iterator on the elements of this list. |
|
E |
remove(int location)
Removes the object at the specified location from this list. |
|
boolean |
remove(Object object)
|
|
protected void |
removeRange(int start,
int end)
Removes the objects in the specified range from the start to the end, but not including the end index. |
|
E |
set(int location,
E object)
Replaces the element at the specified location in this TerracottaList with the specified object. |
|
int |
size()
Returns the number of elements in this TerracottaList. |
|
List<E> |
subList(int start,
int end)
Returns a part of consecutive elements of this list as a view. |
|
Object[] |
toArray()
Returns a new array containing all elements contained in this TerracottaList. |
|
|
toArray(T[] contents)
Returns an array containing all elements contained in this TerracottaList. |
|
void |
trimToSize()
Sets the capacity of this TerracottaList to be the same as the current size. |
|
| Methods inherited from class java.util.AbstractCollection |
|---|
containsAll, removeAll, retainAll, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
containsAll, removeAll, retainAll |
| Field Detail |
|---|
protected transient int modCount
| Constructor Detail |
|---|
public TerracottaList()
TerracottaList with ten capacity.
public TerracottaList(int capacity)
TerracottaList with the specified capacity.
capacity - the initial capacity of this TerracottaList.public TerracottaList(Collection<? extends E> collection)
TerracottaList containing the elements of the specified collection. The
initial size of the TerracottaList will be 10% higher than the size of the specified collection.
collection - the collection of elements to add.| Method Detail |
|---|
public void add(int location,
E object)
TerracottaList at the specified location. The object is inserted
before any previous element at the specified location. If the location is equal to the size of this TerracottaList, the object is added at the end.
add in interface List<E>location - the index at which to insert the object.object - the object to add.
IndexOutOfBoundsException - when location < 0 || > size()public boolean add(E object)
TerracottaList.
add in interface Collection<E>add in interface List<E>add in class AbstractCollection<E>object - the object to add.
public boolean addAll(int location,
Collection<? extends E> collection)
addAll in interface List<E>location - the index at which to insert.collection - the collection of objects.
true if this TerracottaList is modified, false otherwise.
IndexOutOfBoundsException - when location < 0 || > size()public boolean addAll(Collection<? extends E> collection)
TerracottaList.
addAll in interface Collection<E>addAll in interface List<E>addAll in class AbstractCollection<E>collection - the collection of objects.
true if this TerracottaList is modified, false otherwise.public void clear()
TerracottaList, leaving it empty.
clear in interface Collection<E>clear in interface List<E>clear in class AbstractCollection<E>isEmpty(),
size()public Object clone()
TerracottaList with the same elements, the same size and the same capacity as this TerracottaList.
clone in class ObjectTerracottaListCloneablepublic boolean contains(Object object)
TerracottaList for the specified object.
contains in interface Collection<E>contains in interface List<E>contains in class AbstractCollection<E>object - the object to search for.
true if object is an element of this TerracottaList, false otherwisepublic void ensureCapacity(int minimumCapacity)
TerracottaList can hold the specified number of elements without
further growing.
minimumCapacity - the minimum capacity asked for.public E get(int location)
get in interface List<E>public int indexOf(Object object)
indexOf in interface List<E>public boolean isEmpty()
isEmpty in interface Collection<E>isEmpty in interface List<E>isEmpty in class AbstractCollection<E>public int lastIndexOf(Object object)
lastIndexOf in interface List<E>public E remove(int location)
remove in interface List<E>location - the index of the object to remove.
IndexOutOfBoundsException - when location < 0 || >= size()public boolean remove(Object object)
remove in interface Collection<E>remove in interface List<E>remove in class AbstractCollection<E>
protected void removeRange(int start,
int end)
start - the index at which to start removing.end - the index one after the end of the range to remove.
IndexOutOfBoundsException - when start < 0, start > end or end > size()
public E set(int location,
E object)
TerracottaList with the specified object.
set in interface List<E>location - the index at which to put the specified object.object - the object to add.
IndexOutOfBoundsException - when location < 0 || >= size()public int size()
TerracottaList.
size in interface Collection<E>size in interface List<E>size in class AbstractCollection<E>TerracottaList.public Object[] toArray()
TerracottaList.
toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>TerracottaListpublic <T> T[] toArray(T[] contents)
TerracottaList. If the specified array is large
enough to hold the elements, the specified array is used, otherwise an array of the same type is created. If the
specified array is used and is larger than this TerracottaList, the array element following the collection
elements is set to null.
toArray in interface Collection<E>toArray in interface List<E>toArray in class AbstractCollection<E>contents - the array.
TerracottaList.
ArrayStoreException - when the type of an element in this TerracottaList cannot be stored in the type
of the specified array.public void trimToSize()
TerracottaList to be the same as the current size.
size()public boolean equals(Object object)
equals in interface Collection<E>equals in interface List<E>equals in class Objectobject - the object to compare to this object.
true if the specified object is equal to this list, false otherwise.hashCode()public int hashCode()
hashCode in interface Collection<E>hashCode in interface List<E>hashCode in class Objectequals(java.lang.Object),
List.hashCode()public Iterator<E> iterator()
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface List<E>iterator in class AbstractCollection<E>Iteratorpublic ListIterator<E> listIterator()
listIterator in interface List<E>ListIteratorpublic ListIterator<E> listIterator(int location)
listIterator in interface List<E>location - the index at which to start the iteration.
IndexOutOfBoundsException - if location < 0 || location > size()ListIterator
public List<E> subList(int start,
int end)
This method can be used as a handy method to do some operations on a sub range of the original list, for example
list.subList(from, to).clear();
If the original list is modified in other ways than through the returned subList, the behavior of the returned subList becomes undefined.
The returned subList is a subclass of TerracottaList. The subclass stores offset, size of itself, and modCount of the original list. If the original list implements RandomAccess interface, the returned subList also implements RandomAccess interface.
The subList's set(int, Object), get(int), add(int, Object), remove(int), addAll(int, Collection) and removeRange(int, int) methods first check the bounds, adjust offsets and then call the corresponding methods of the original TerracottaList. addAll(Collection c) method of the returned subList calls the original addAll(offset + size, c).
The listIterator(int) method of the subList wraps the original list iterator. The iterator() method of the subList invokes the original listIterator() method, and the size() method merely returns the size of the subList.
All methods will throw a ConcurrentModificationException if the modCount of the original list is not equal to the expected value.
subList in interface List<E>start - start index of the subList (inclusive).end - end index of the subList, (exclusive).
start (inclusive), and ending with end
(exclusive)
IndexOutOfBoundsException - if (start < 0 || end > size())
IllegalArgumentException - if (start > end)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||