| java.lang.Object javax.media.j3d.IndexedUnorderSet
IndexedUnorderSet | class IndexedUnorderSet implements Cloneable,java.io.Serializable(Code) | | A strongly type indexed unorder set.
All operations remove(IndexedObject, ListType), add(IndexedObject, ListType),
contains(IndexedObject, ListType) etc. take O(1) time.
The class is designed to optimize speed. So many reductance
procedures call and range check as found in ArrayList are
removed.
Use the following code to iterate through an array.
IndexedUnorderSet IUset =
new IndexedUnorderSet(YourClass.class, listType);
// add element here
YourClass[] arr = (YourClass []) IUset.toArray();
int size = IUset.arraySize();
for (int i=0; i < size; i++) {
YourClass obj = arr[i];
....
}
Note:
1) The array return is a copied of internal array.
2) Don't use arr.length , use IUset.arraySize();
3) IndexedObject contains an array of listIndex, the number of
array elements depends on the number of different types of
IndexedUnorderSet that use it.
4) No need to do casting for individual element as in ArrayList.
5) IndexedUnorderSet is thread safe.
6) Object implement this interface MUST initialize the index to -1.
Limitation:
1) Order of IndexedObject in list is not important
2) Can't modify the clone() copy.
3) IndexedObject can't be null
|
Method Summary | |
final synchronized void | add(IndexedObject o) Appends the specified element to the end of this list. | final int | arraySize() Returns the size of entry use in toArray() number of elements
in this list. | final synchronized void | clear() Removes all of the elements from this list. | final synchronized void | clearMirror() | final protected synchronized Object | clone() Returns a shallow copy of this ArrayList instance. | final synchronized boolean | contains(IndexedObject o) Returns true if this list contains the specified element. | final synchronized Object | get(int index) Returns the element at the specified position in this list.
Parameters: index - index of element to return. | final Class | getComponentType() | final synchronized int | indexOf(IndexedObject o) Searches for the last occurence of the given argument, testing
for equality using the equals method. | final static void | init(IndexedObject obj, int len) | final boolean | isEmpty() Tests if this list has no elements. | final synchronized void | remove(int index) Removes the element at the specified position in this list. | final synchronized boolean | remove(IndexedObject o) Removes the specified element in this list.
Replace the removed element by the last one.
Parameters: o - the element to removed. | final synchronized Object | removeLastElement() Removes the element at the last position in this list. | final synchronized void | set(int index, IndexedObject o) Replaces the element at the specified position in this list with
the specified element.
Parameters: index - index of element to replace. Parameters: o - element to be stored at the specified position. | final int | size() Returns the number of elements in this list. | final synchronized Object[] | toArray(boolean copy) Returns an array containing all of the elements in this list.
The size of the array may longer than the actual size. | final synchronized Object[] | toArray() Returns an array containing all of the elements in this list.
The size of the array may longer than the actual size. | final synchronized Object[] | toArray(IndexedObject startElement) Returns an array containing elements starting from startElement
all of the elements in this list. | final synchronized void | trimToSize() Trims the capacity of this ArrayList instance to be the
list's current size. |
cloneData | transient Object cloneData(Code) | | Clone copy of elementData return by toArray(true);
|
cloneSize | transient int cloneSize(Code) | | |
componentType | Class componentType(Code) | | Component Type of individual array element entry
|
debug | final static boolean debug(Code) | | |
elementData | transient IndexedObject elementData(Code) | | The array buffer into which the elements of the ArrayList are stored.
The capacity of the ArrayList is the length of this array buffer.
It is non-private to enable compiler do inlining for get(),
set(), remove() when -O flag turn on.
|
isDirty | transient boolean isDirty(Code) | | |
size | int size(Code) | | The size of the ArrayList (the number of elements it contains).
We make it non-private to enable compiler do inlining for
getSize() when -O flag turn on.
|
IndexedUnorderSet | IndexedUnorderSet(int initialCapacity, Class componentType, int listType, VirtualUniverse univ)(Code) | | Constructs an empty list with the specified initial capacity.
and the class data Type
Parameters: initialCapacity - the initial capacity of the list. Parameters: componentType - class type of element in the list. |
IndexedUnorderSet | IndexedUnorderSet(Class componentType, int listType, VirtualUniverse univ)(Code) | | Constructs an empty list.
Parameters: componentType - class type of element in the list. |
IndexedUnorderSet | IndexedUnorderSet(int initialCapacity, int listType, VirtualUniverse univ)(Code) | | Constructs an empty list with the specified initial capacity.
Parameters: initialCapacity - the initial capacity of the list. |
IndexedUnorderSet | IndexedUnorderSet(int listType, VirtualUniverse univ)(Code) | | Constructs an empty list.
Parameters: listType - default to Object. |
add | final synchronized void add(IndexedObject o)(Code) | | Appends the specified element to the end of this list.
It is the user responsible to ensure that the element add is of
the same type as array componentType.
Parameters: o - element to be appended to this list. |
arraySize | final int arraySize()(Code) | | Returns the size of entry use in toArray() number of elements
in this list.
the number of elements in this list. |
clear | final synchronized void clear()(Code) | | Removes all of the elements from this list. The list will
be empty after this call returns.
|
clearMirror | final synchronized void clearMirror()(Code) | | |
clone | final protected synchronized Object clone()(Code) | | Returns a shallow copy of this ArrayList instance. (The
elements themselves are not copied.)
a clone of this ArrayList instance. |
contains | final synchronized boolean contains(IndexedObject o)(Code) | | Returns true if this list contains the specified element.
Parameters: o - element whose presence in this List is to be tested. |
get | final synchronized Object get(int index)(Code) | | Returns the element at the specified position in this list.
Parameters: index - index of element to return. the element at the specified position in this list. throws: IndexOutOfBoundsException - if index is out of range (index< 0 || index >= size()). |
indexOf | final synchronized int indexOf(IndexedObject o)(Code) | | Searches for the last occurence of the given argument, testing
for equality using the equals method.
Parameters: o - an object. the index of the first occurrence of the argument in thislist; returns -1 if the object is not found. See Also: Object.equals(Object) |
isEmpty | final boolean isEmpty()(Code) | | Tests if this list has no elements.
true if this list has no elements;false otherwise. |
remove | final synchronized void remove(int index)(Code) | | Removes the element at the specified position in this list.
Replace the removed element by the last one.
Parameters: index - the index of the element to removed. throws: IndexOutOfBoundsException - if index out of range (index< 0 || index >= size()). |
remove | final synchronized boolean remove(IndexedObject o)(Code) | | Removes the specified element in this list.
Replace the removed element by the last one.
Parameters: o - the element to removed. true if object remove throws: IndexOutOfBoundsException - if index out of range (index< 0 || index >= size()). |
removeLastElement | final synchronized Object removeLastElement()(Code) | | Removes the element at the last position in this list.
The element remove throws: IndexOutOfBoundsException - if array is empty |
set | final synchronized void set(int index, IndexedObject o)(Code) | | Replaces the element at the specified position in this list with
the specified element.
Parameters: index - index of element to replace. Parameters: o - element to be stored at the specified position. the element previously at the specified position. throws: IndexOutOfBoundsException - if index out of range(index < 0 || index >= size()). |
size | final int size()(Code) | | Returns the number of elements in this list.
the number of elements in this list. |
toArray | final synchronized Object[] toArray(boolean copy)(Code) | | Returns an array containing all of the elements in this list.
The size of the array may longer than the actual size. Use
arraySize() to retrieve the size.
The array return is a copied of internal array. if copy
is true.
an array containing all of the elements in this list |
toArray | final synchronized Object[] toArray()(Code) | | Returns an array containing all of the elements in this list.
The size of the array may longer than the actual size. Use
arraySize() to retrieve the size.
The array return is a copied of internal array. So another
thread can continue add/delete the current list. However,
it should be noticed that two call to toArray() may return
the same copy.
an array containing all of the elements in this list |
toArray | final synchronized Object[] toArray(IndexedObject startElement)(Code) | | Returns an array containing elements starting from startElement
all of the elements in this list. A new array of exact size
is always allocated.
Parameters: startElement - starting element to copy an array containing elements starting fromstartElement, null if element not found. |
trimToSize | final synchronized void trimToSize()(Code) | | Trims the capacity of this ArrayList instance to be the
list's current size. An application can use this operation to minimize
the storage of an ArrayList instance.
|
|
|