|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
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.ImmutableArrayList
public class ImmutableArrayList
Implementation of the Collection Framework interface "List" in a read- only fashion on top of an array data structure.
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.
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()
, and getSortedSet()
methods should be used.
Nested Class Summary | |
---|---|
protected class |
ImmutableArrayList.ListView ListView exposes the underlying ImmutableArrayList through the List interface, maintaining correct equals() and hashCode() semantics |
protected class |
ImmutableArrayList.SetView SetView exposes the underlying ImmutableArrayList through the Set interface, maintaining correct equals() and hashCode() semantics |
protected class |
ImmutableArrayList.SortedSetView SetView exposes the underlying ImmutableArrayList through the SortedSet interface, maintaining correct equals() and hashCode() semantics |
Field Summary |
---|
Fields inherited from class java.util.AbstractList |
---|
modCount |
Constructor Summary | |
---|---|
ImmutableArrayList() Default constructor (necessary for the ExternalizableLite interface). |
|
ImmutableArrayList(java.util.Collection collection) Construct a List containing the elements of the specified Collection. |
|
ImmutableArrayList(java.lang.Object[] ao) Construct a List from an array. |
|
ImmutableArrayList(java.lang.Object[] ao, int of, int c) Construct a List from a specified number of items in an array starting at the specified offset. |
Method Summary | |
---|---|
java.lang.Object |
clone() Create a clone of the ImmutableArrayList. |
java.util.Comparator |
comparator() Returns the comparator associated with this sorted set, or null if it uses its elements' natural ordering. |
int |
compareTo(java.lang.Object o) Compare this ImmutableArrayList with the passed Object to determine order. |
boolean |
contains(java.lang.Object o) Returns true if this List contains the specified element. |
boolean |
equals(java.lang.Object o) Compare this Collection / List / Set / SortedSet with some other Object and determine if the caller would believe this Object to equal that other Object. |
java.lang.Object |
first() Returns the first element currently in this sorted set. |
java.lang.Object |
get(int i) Returns the element at the specified position in this List. |
java.util.List |
getList() Return a java.util.List view of this ImmutableArrayList. |
java.util.Set |
getSet() Return a java.util.Set view of this ImmutableArrayList. |
java.util.SortedSet |
getSortedSet() Return a java.util.SortedSet view of this ImmutableArrayList. |
protected java.util.Map |
getValueIndex() Create a reverse index from value to position if this List is big enough to warrant it. |
java.util.SortedSet |
headSet(java.lang.Object toElement) Returns a view of the portion of this sorted set whose elements are found in the set in a position before toElement. |
int |
indexOf(java.lang.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. |
java.util.Iterator |
iterator() Returns an iterator over the elements in this list in proper sequence. |
java.lang.Object |
last() Returns the last element currently in this sorted set. |
int |
lastIndexOf(java.lang.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. |
void |
readExternal(java.io.DataInput in) Restore the contents of this object by loading the object's state from the passed DataInput object. |
int |
size() Returns the number of elements in this List. |
java.util.SortedSet |
subSet(java.lang.Object fromElement, java.lang.Object toElement) Returns a view of the portion of this sorted set whose elements are found in the set in a position at and after the position of fromElement and in a position before toElement. |
java.util.SortedSet |
tailSet(java.lang.Object fromElement) Returns a view of the portion of this sorted set whose elements are found in the set in a position at and after the position of fromElement. |
java.lang.Object[] |
toArray() Returns an array containing all of the elements in this List in the order that the elements occur in the List. |
java.lang.Object[] |
toArray(java.lang.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. |
void |
writeExternal(java.io.DataOutput out) Save the contents of this object by storing the object's state into the passed DataOutput object. |
Methods inherited from class java.util.AbstractList |
---|
add, add, addAll, clear, hashCode, listIterator, listIterator, remove, removeRange, set, subList |
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, listIterator, remove, remove, removeAll, retainAll, set, subList |
Constructor Detail |
---|
public ImmutableArrayList(java.lang.Object[] ao, int of, int c)
ao
- a non-null array of Objectsof
- an offset of the first item in the arrayc
- the number of items to usepublic ImmutableArrayList(java.lang.Object[] ao)
ao
- a non-null array of Objectspublic ImmutableArrayList(java.util.Collection collection)
collection
- the Collection to fill this List frompublic ImmutableArrayList()
Method Detail |
---|
public java.util.List getList()
public java.util.Set getSet()
Note: this method does not ensure that the underlying ImmutableArrayList adheres to the Set contract. It is the responsibility of the user to ensure that the elements are unique if the object is used as a Set.
public java.util.SortedSet getSortedSet()
Note: this method does not ensure that the underlying ImmutableArrayList adheres to the SortedSet contract. It is the responsibility of the user to ensure that the elements are unique and ordered if the object is used as a SortedSet.
public int size()
size
in interface java.util.Collection
size
in interface java.util.List
size
in interface java.util.Set
size
in class java.util.AbstractCollection
public java.lang.Object get(int i)
get
in interface java.util.List
get
in class java.util.AbstractList
i
- the index of the element to returnjava.lang.IndexOutOfBoundsException
- if the index is out of range (index < 0 || index >= size()).public int indexOf(java.lang.Object o)
indexOf
in interface java.util.List
indexOf
in class java.util.AbstractList
o
- element to search for.public int lastIndexOf(java.lang.Object o)
lastIndexOf
in interface java.util.List
lastIndexOf
in class java.util.AbstractList
o
- element to search for.public boolean contains(java.lang.Object o)
contains
in interface java.util.Collection
contains
in interface java.util.List
contains
in interface java.util.Set
contains
in class java.util.AbstractCollection
o
- element whose presence in this List is to be testedpublic java.lang.Object[] toArray()
toArray
in interface java.util.Collection
toArray
in interface java.util.List
toArray
in interface java.util.Set
toArray
in class java.util.AbstractCollection
public java.lang.Object[] toArray(java.lang.Object[] ao)
If the List fits in the specified array with room to spare (i.e., the array has more elements than the List), the element in the array immediately following the end of the last element is set to null. This is useful in determining the length of the List only if the caller knows that the List does not contain any null elements.)
toArray
in interface java.util.Collection
toArray
in interface java.util.List
toArray
in interface java.util.Set
toArray
in class java.util.AbstractCollection
ao
- the array into which the elements of the List are to be stored, if it is big enough; otherwise, ao new array of the same runtime type is allocated for this purposejava.lang.ArrayStoreException
- if the runtime type of the specified array is not ao supertype of the runtime type of every element in this Listpublic java.util.Iterator iterator()
iterator
in interface java.lang.Iterable
iterator
in interface java.util.Collection
iterator
in interface java.util.List
iterator
in interface java.util.Set
iterator
in class java.util.AbstractList
public java.util.Comparator comparator()
comparator
in interface java.util.SortedSet
public java.lang.Object first()
first
in interface java.util.SortedSet
java.util.NoSuchElementException
- if the sorted set is emptypublic java.lang.Object last()
last
in interface java.util.SortedSet
java.util.NoSuchElementException
- if the sorted set is emptypublic java.util.SortedSet headSet(java.lang.Object toElement)
headSet
in interface java.util.SortedSet
toElement
- high endpoint (exclusive) of the headSetjava.lang.IllegalArgumentException
- if toElement is not found in the SortedSetpublic java.util.SortedSet tailSet(java.lang.Object fromElement)
tailSet
in interface java.util.SortedSet
fromElement
- the first element to include in the resulting setjava.lang.IllegalArgumentException
- if fromElement is not found in the SortedSetpublic java.util.SortedSet subSet(java.lang.Object fromElement, java.lang.Object toElement)
subSet
in interface java.util.SortedSet
fromElement
- the first element to include in the resulting settoElement
- the first element following fromElement to not include in the resulting setjava.lang.IllegalArgumentException
- if either fromElement or toElement is not found in the SortedSetpublic java.lang.Object clone()
public void readExternal(java.io.DataInput in) throws java.io.IOException
readExternal
in interface ExternalizableLite
in
- the DataInput stream to read data from in order to restore the state of this objectjava.io.IOException
- if an I/O exception occursjava.io.NotActiveException
- if the object is not in its initial state, and therefore cannot be deserialized intopublic void writeExternal(java.io.DataOutput out) throws java.io.IOException
writeExternal
in interface ExternalizableLite
out
- the DataOutput stream to write the state of this object tojava.io.IOException
- if an I/O exception occurspublic int compareTo(java.lang.Object o)
All elements contained in both Lists must implement the Comparable interface. This method will compare the corresponding list element left-to-right and will immediately return the first non-zero comparison result. (A null element is always considered to be "less than" any non-null element.)
If all corresponding elements are equal, this method will return a negative integer if the size of this List is less than the size of the specified List, a positive integer if the size of this List is greater, and zero if the Lists are equal.
compareTo
in interface java.lang.Comparable
o
- the Object to be comparedjava.lang.ClassCastException
- if the specified object does not implement the List
interface, some elements of either list do not implement the Comparable
interface, or if an element object type prevents it from being compared to another elementjava.lang.NullPointerException
- if the specified List itself or any of its elements are nullpublic boolean equals(java.lang.Object o)
equals
in interface java.util.Collection
equals
in interface java.util.List
equals
in interface java.util.Set
equals
in class java.util.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)protected java.util.Map getValueIndex()
|
Oracle® Coherence Java API Reference Release 12.1.2.0.3 E26043-02 |
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |