|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.cosylab.util.ObjectList
public class ObjectList
A simple resizable threadsafe array. Offers minimal capability and overhead
for all operations except toArray(Class). The main cost of the
array maintainance is in the addition and removal of the elements. The
potential traversals are very fast, because they can occur outside the
synchronized blocks of code through normal arrays. The arrays returned by
the toArray methods are of the correct runtime type. If, for
example, the type of the list was specified to be X, the
following cast is permitted:
X[] array = (X[])list.toArray()
| Constructor Summary | |
|---|---|
ObjectList(java.lang.Class type)
Creates a new ObjectList object. |
|
| Method Summary | |
|---|---|
void |
add(int index,
java.lang.Object o)
Adds an object to this list. |
boolean |
add(java.lang.Object o)
Adds an object to this list. |
void |
add(java.lang.Object o,
int index)
Deprecated. replaced by add(int, Object) |
boolean |
addAll(java.util.Collection c)
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. |
boolean |
addAll(int index,
java.util.Collection c)
Inserts all of the elements in the specified Collection into this list, starting at the specified position. |
void |
clear()
Empties this list. |
boolean |
contains(java.lang.Object o)
Checks if the list contains a given element. |
boolean |
containsAll(java.util.Collection c)
Returns true if this collection contains all of the elements in the specified collection. |
java.lang.Object |
get(int index)
Returns the object at the specified index |
int |
indexOf(java.lang.Object o)
Searches for the first occurence of the given argument, testing for equality using the equals method. |
boolean |
isEmpty()
Tests if this list has no elements. |
java.util.Iterator |
iterator()
Returns iterator which iterates over elements, which was contained in list at the moment iterator was called. |
int |
lastIndexOf(java.lang.Object elem)
Returns the index of the last occurrence of the specified object in this list. |
java.util.ListIterator |
listIterator()
Returns a list iterator of the elements in this list, iterator will iterate over the elements, which were in list at the moment iterator was created thus iteration will not fail if list is modified during iteration. |
java.util.ListIterator |
listIterator(int index)
Returns iterator which iterates over elements, which was contained in list at the moment iterator was called. |
java.lang.Object |
remove(int index)
Removes the element at the specified position in this list (optional operation). |
boolean |
remove(java.lang.Object o)
Removes an element from the list. |
boolean |
removeAll(java.util.Collection c)
Removes the elements that are contained in the collection. |
boolean |
retainAll(java.util.Collection c)
Removes all elements but those contained in the collection. |
java.lang.Object |
set(int index,
java.lang.Object element)
Sets the element at specified index to specified object. |
int |
size()
Returns the size of the list. |
java.util.List |
subList(int fromIndex,
int toIndex)
Deprecated. This method is not implemented. |
java.lang.Object[] |
toArray()
Returns the elements of this list. |
java.lang.Object[] |
toArray(java.lang.Class type)
Returns all objects in the list which are subtypes of the class parameter. |
java.lang.Object[] |
toArray(java.lang.Object[] a)
Returns an array containing all of the elements in this list. |
java.lang.String |
toString()
Produces a string rendering of this instance by enumerating all members. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public ObjectList(java.lang.Class type)
type - the type of objects this list will hold
java.lang.NullPointerException - if the type is null| Method Detail |
|---|
public void add(java.lang.Object o,
int index)
add(int, Object)
o - object to add to the collectionindex - where the object should be insertedpublic boolean add(java.lang.Object o)
add in interface java.util.Collectionadd in interface java.util.Listo - object to add to the collection
List.add(Object)public boolean remove(java.lang.Object o)
remove in interface java.util.Collectionremove in interface java.util.Listo - element to be removed from this list, if present.
List.remove(java.lang.Object)public int size()
size in interface java.util.Collectionsize in interface java.util.Listpublic java.lang.Object[] toArray(java.lang.Class type)
class parameter. This necessitates the construction of a
new array which must occur in a synchronized block of code. This method
therefore takes some time to execute.
type - the type of the objects to look for
type
java.lang.NullPointerException - when type is null
java.lang.IllegalArgumentException - if type is not a
subtype of the type specified as the constructor parameterpublic java.lang.Object[] toArray()
add and remove() methods of this class.
toArray in interface java.util.CollectiontoArray in interface java.util.Listpublic boolean contains(java.lang.Object o)
equals.
Uses linear search.
contains in interface java.util.Collectioncontains in interface java.util.Listo - the object to look for
true iff the list contains object o.public java.lang.Object get(int index)
get in interface java.util.Listindex - the index of the requested object
public int indexOf(java.lang.Object o)
indexOf in interface java.util.Listo - an object.
Object.equals(Object)public java.lang.String toString()
Object.toString.
toString in class java.lang.Objectpublic void clear()
clear in interface java.util.Collectionclear in interface java.util.Listpublic java.util.Iterator iterator()
iterator in interface java.lang.Iterableiterator in interface java.util.Collectioniterator in interface java.util.Listpublic boolean isEmpty()
isEmpty in interface java.util.CollectionisEmpty in interface java.util.Listpublic java.lang.Object remove(int index)
remove in interface java.util.Listindex - the index of the element to removed.
java.lang.IndexOutOfBoundsException - DOCUMENT ME!
public void add(int index,
java.lang.Object o)
add in interface java.util.Listindex - where the object should be insertedo - object to add to the collection
java.lang.NullPointerException
java.lang.ClassCastException - if the RTT of o is not assignable to the
type specified in the constructorList.add(int, Object)public int lastIndexOf(java.lang.Object elem)
lastIndexOf in interface java.util.Listelem - the desired element.
List.lastIndexOf(java.lang.Object)
public boolean addAll(int index,
java.util.Collection c)
addAll in interface java.util.Listindex - index at which to insert first element from the specified
collection.c - elements to be inserted into this list.
List.addAll(int, java.util.Collection)public boolean addAll(java.util.Collection c)
addAll in interface java.util.CollectionaddAll in interface java.util.Listc - the elements to be inserted into this list.
List.addAll(java.util.Collection)public boolean containsAll(java.util.Collection c)
This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained true is returned, otherwise false.
containsAll in interface java.util.CollectioncontainsAll in interface java.util.Listc - collection to be checked for containment in this collection.
contains(Object),
List.containsAll(java.util.Collection)public boolean removeAll(java.util.Collection c)
removeAll in interface java.util.CollectionremoveAll in interface java.util.Listc - the collection of elements to be removed
true if at least one element is removedList.removeAll(java.util.Collection)public boolean retainAll(java.util.Collection c)
retainAll in interface java.util.CollectionretainAll in interface java.util.Listc - the collection of elements to keep
true if at lest one element is removedList.retainAll(java.util.Collection)
public java.util.List subList(int fromIndex,
int toIndex)
subList in interface java.util.ListfromIndex - DOCUMENT ME!toIndex - DOCUMENT ME!
java.lang.UnsupportedOperationException - when invokedList.subList(int, int)public java.util.ListIterator listIterator(int index)
listIterator in interface java.util.Listindex - index of the first element to be returned from the list
iterator (by a call to the next method).
java.lang.IndexOutOfBoundsException - if the specified index is out of range
(index < 0 || index > size()).List.listIterator(int)
public java.lang.Object set(int index,
java.lang.Object element)
set in interface java.util.Listindex - the index of object to setelement - the object to be set to the index
java.lang.NullPointerException - DOCUMENT ME!
java.lang.ClassCastException - DOCUMENT ME!List.set(int, Object)public java.lang.Object[] toArray(java.lang.Object[] a)
toArray in interface java.util.CollectiontoArray in interface java.util.Lista - the array into which the elements of this list are to be
stored, if it is big enough; otherwise, a new array is
allocated for this purpose.
java.lang.NullPointerException - if the specified array is null.
java.lang.ArrayStoreException - if the runtime type of the specified array
is not a supertype of the runtime type of every element in this
list.List.toArray(java.lang.Object[])public java.util.ListIterator listIterator()
listIterator in interface java.util.ListList.listIterator(int)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||