|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
java.util.AbstractCollection
java.util.AbstractList
com.tangosol.util.ImmutableMultiList
public class ImmutableMultiList
Implementation of the List interface in a read-only fashion based on a collection of arrays. <p/> This class also implements the Set interface, although the contents are not checked to determine whether each element is unique. It is the responsibility of the user to ensure that the elements are unique if the object is used as a Set. <p/> Note: while preserved for backward compatibility, as of Coherence 3.6, use of this class specifically as a List or a Set is deprecated. Instead, the getList()
, getSet()
methods should be used.
ImmutableArrayList
Nested Class Summary | |
---|---|
protected class |
ImmutableMultiList.ListView ListView exposes the underlying ImmutableMultiList through the List interface, maintaining correct equals() and hashCode() semantics |
protected class |
ImmutableMultiList.MultiIterator ListIterator implementation based on the ImmutableMultiList. |
protected class |
ImmutableMultiList.SetView SetView exposes the underlying ImmutableMultiList through the Set interface, maintaining correct equals() and hashCode() semantics |
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
ImmutableMultiList(Collection collection) Construct a List containing the elements of the specified Collection of Object arrays. |
|
ImmutableMultiList(Object[][] aao) Construct a List containing the elements of the specified array of Object arrays. |
Method Summary | |
---|---|
static int |
calculateTotalLength(Object[][] aao) Calculate the total number of element in the array of arrays. |
boolean |
contains(Object o) Returns true if this List contains the specified element. |
boolean |
equals(Object o) Compare this Collection / List / Set with some other Object and determine if the caller would believe this Object to equal that other Object. |
static Object[] |
flatten(Object[][] aaoFrom, int cTotal, Object[] aoTo) Create a single dimensional array containing all elements of the specified array of arrays. |
Object |
get(int i) Returns the element at the specified position in this List. |
List |
getList() Return a java.util.List view of this ImmutableMultiList. |
Set |
getSet() Return a java.util.Set view of this ImmutableMultiList. |
int |
indexOf(Object o) Returns the index in this List of the first occurrence of the specified element, or -1 if this List does not contain this element. |
Iterator |
iterator() Returns an iterator over the elements in this list in proper sequence. |
int |
lastIndexOf(Object o) Returns the index in this List of the last occurrence of the specified element, or -1 if this List does not contain this element. |
ListIterator |
listIterator() Returns an iterator of the elements in this list (in proper sequence). |
ListIterator |
listIterator2(int i) |
int |
size() Returns the number of elements in this List. |
List |
subList(int iFrom, int iTo) Returns a view of the portion of this list between fromIndex, inclusive, and toIndex, exclusive. |
Object[] |
toArray() Returns an array containing all of the elements in this List in the order that the elements occur in the List. |
Object[] |
toArray(Object[] ao) Returns an array with ao runtime type is that of the specified array and that contains all of the elements in this List. |
Methods inherited from class java.util.AbstractList |
---|
add, add, addAll, clear, hashCode, listIterator, remove, removeRange, set |
Methods inherited from class java.util.AbstractCollection |
---|
addAll, containsAll, isEmpty, remove, removeAll, retainAll, toString |
Methods inherited from interface java.util.List |
---|
add, add, addAll, addAll, clear, containsAll, hashCode, isEmpty, listIterator, remove, remove, removeAll, retainAll, set |
Methods inherited from interface java.util.Set |
---|
add, addAll, clear, containsAll, hashCode, isEmpty, remove, removeAll, retainAll |
Constructor Detail |
---|
public ImmutableMultiList(Object[][] aao)
aao
- the array of arrays backing the MultiListpublic ImmutableMultiList(Collection collection)
collection
- the Collection of arrays to fill this MultiList fromMethod Detail |
---|
public List getList()
public Set getSet()
public int size()
size
in interface Collection
size
in interface List
size
in interface Set
size
in class AbstractCollection
public Object get(int i)
get
in interface List
get
in class AbstractList
i
- the index of the element to returnIndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).public int indexOf(Object o)
indexOf
in interface List
indexOf
in class AbstractList
o
- element to search for.public int lastIndexOf(Object o)
lastIndexOf
in interface List
lastIndexOf
in class AbstractList
o
- element to search for.public boolean contains(Object o)
contains
in interface Collection
contains
in interface List
contains
in interface Set
contains
in class AbstractCollection
o
- element whose presence in this List is to be testedpublic Object[] toArray()
toArray
in interface Collection
toArray
in interface List
toArray
in interface Set
toArray
in class AbstractCollection
Arrays.asList(Object[])
public Object[] toArray(Object[] ao)
toArray
in interface Collection
toArray
in interface List
toArray
in interface Set
toArray
in class AbstractCollection
ao
- the array into which the elements of the MultiList are to be stored, if it is big enough; otherwise, ao new array of the same runtime type is allocated for this purposeArrayStoreException
- if the runtime type of the specified array is not ao supertype of the runtime type of every element in this MultiListpublic ListIterator listIterator()
listIterator
in interface List
listIterator
in class AbstractList
AbstractList.listIterator(int)
public ListIterator listIterator2(int i)
public List subList(int iFrom, int iTo)
This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by operating on a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:
list.subList(from, to).clear();Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList.
The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of the list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
This implementation returns a list that subclasses AbstractList. The subclass stores, in private fields, the offset of the subList within the backing list, the size of the subList (which can change over its lifetime), and the expected modCount value of the backing list. There are two variants of the subclass, one of which implements RandomAccess. If this list implements RandomAccess the returned list will be an instance of the subclass that implements RandomAccess.
The subclass's set(int, Object), get(int), add(int, Object), remove(int), addAll(int, Collection) and removeRange(int, int) methods all delegate to the corresponding methods on the backing abstract list, after bounds-checking the index and adjusting for the offset. The addAll(Collection c) method merely returns addAll(size, c).
The listIterator(int) method returns a "wrapper object" over a list iterator on the backing list, which is created with the corresponding method on the backing list. The iterator method merely returns listIterator(), and the size method merely returns the subclass's size field.
All methods first check to see if the actual modCount of the backing list is equal to its expected value, and throw a ConcurrentModificationException if it is not.
subList
in interface List
subList
in class AbstractList
iFrom
- low endpoint (inclusive) of the subList.iTo
- high endpoint (exclusive) of the subList.public Iterator iterator()
iterator
in interface Iterable
iterator
in interface Collection
iterator
in interface List
iterator
in interface Set
iterator
in class AbstractList
AbstractList.modCount
public boolean equals(Object o)
equals
in interface Collection
equals
in interface List
equals
in interface Set
equals
in class AbstractList
o
- some other Object that is likely to be a Collection or some more specific type (with its related overloaded definition of what it thinks that equals() means)Object.equals(Object)
, Set.equals(Object)
, List.equals(Object)
public static int calculateTotalLength(Object[][] aao)
aao
- an array of arrayspublic static Object[] flatten(Object[][] aaoFrom, int cTotal, Object[] aoTo)
aaoFrom
- an array of arrays to copy fromcTotal
- the total length of the flattened array; pass -1 for it to be calculatedaoTo
- an array to copy the elements into (optional)ArrayIndexOutOfBoundsException
- if the total length parameter was not sufficient to hold the flattened array
|
Oracle® Coherence Java API Reference Release 3.6.0.0 E15725-01 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |