Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.1.0

E18814-01


com.tangosol.util
Class InflatableList

java.lang.Object
  extended by java.util.AbstractCollection
      extended by com.tangosol.util.InflatableCollection
          extended by com.tangosol.util.InflatableList

All Implemented Interfaces:
java.lang.Iterable, java.util.Collection, java.util.List

public class InflatableList
extends InflatableCollection
implements java.util.List

Specialization of InflatableCollection that surfaces as a List.

Since:
Coherence 3.6
Author:
ch 2009.11.22

Field Summary

 

Fields inherited from class com.tangosol.util.InflatableCollection
m_colValue, m_oValue, NO_VALUE

 

Constructor Summary
InflatableList()
           

 

Method Summary
 void add(int i, java.lang.Object o)
          Inserts the specified element at the specified position in this list (optional operation).
 boolean addAll(int i, java.util.Collection col)
          Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
 boolean equals(java.lang.Object o)
          Compares the specified object with this collection for equality.

While the Collection interface adds no stipulations to the general contract for the Object.equals, programmers who implement the Collection interface "directly" (in other words, create a class that is a Collection but is not a Set or a List) must exercise care if they choose to override the Object.equals. It is not necessary to do so, and the simplest course of action is to rely on Object's implementation, but the implementer may wish to implement a "value comparison" in place of the default "reference comparison." (The List and Set interfaces mandate such value comparisons.)

The general contract for the Object.equals method states that equals must be symmetric (in other words, a.equals(b) if and only if b.equals(a)). The contracts for List.equals and Set.equals state that lists are only equal to other lists, and sets to other sets. Thus, a custom equals method for a collection class that implements neither the List nor Set interface must return false when this collection is compared to any list or set. (By the same logic, it is not possible to write a class that correctly implements both the Set and List interfaces.)

 java.lang.Object get(int i)
          Returns the element at the specified position in this list.
 int hashCode()
          Returns the hash code value for this collection. While the Collection interface adds no stipulations to the general contract for the Object.hashCode method, programmers should take note that any class that overrides the Object.equals method must also override the Object.hashCode method in order to satisfy the general contract for the Object.hashCodemethod. In particular, c1.equals(c2) implies that c1.hashCode()==c2.hashCode().
 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.
protected  java.util.Collection instantiateCollection()
          Factory method used to create a new Collection.
 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.
 java.util.ListIterator listIterator()
          Returns a list iterator of the elements in this list (in proper sequence).
 java.util.ListIterator listIterator(int i)
          Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
 java.lang.Object remove(int i)
          Removes the element at the specified position in this list (optional operation).
 java.lang.Object set(int i, java.lang.Object o)
          Replaces the element at the specified position in this list with the specified element (optional operation).
 java.util.List subList(int iFrom, int iTo)
          Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

 

Methods inherited from class com.tangosol.util.InflatableCollection
add, clear, contains, iterator, remove, size, toArray, toArray

 

Methods inherited from class java.util.AbstractCollection
addAll, containsAll, isEmpty, removeAll, retainAll, toString

 

Methods inherited from interface java.util.List
add, addAll, clear, contains, containsAll, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

 

Constructor Detail

InflatableList

public InflatableList()

Method Detail

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this collection for equality.

While the Collection interface adds no stipulations to the general contract for the Object.equals, programmers who implement the Collection interface "directly" (in other words, create a class that is a Collection but is not a Set or a List) must exercise care if they choose to override the Object.equals. It is not necessary to do so, and the simplest course of action is to rely on Object's implementation, but the implementer may wish to implement a "value comparison" in place of the default "reference comparison." (The List and Set interfaces mandate such value comparisons.)

The general contract for the Object.equals method states that equals must be symmetric (in other words, a.equals(b) if and only if b.equals(a)). The contracts for List.equals and Set.equals state that lists are only equal to other lists, and sets to other sets. Thus, a custom equals method for a collection class that implements neither the List nor Set interface must return false when this collection is compared to any list or set. (By the same logic, it is not possible to write a class that correctly implements both the Set and List interfaces.)

Specified by:
equals in interface java.util.Collection
Specified by:
equals in interface java.util.List
Overrides:
equals in class InflatableCollection
Parameters:
o - Object to be compared for equality with this collection.
Returns:
true if the specified object is equal to this collection
See Also:
Object.equals(Object), Set.equals(Object), List.equals(Object)

hashCode

public int hashCode()
Returns the hash code value for this collection. While the Collection interface adds no stipulations to the general contract for the Object.hashCode method, programmers should take note that any class that overrides the Object.equals method must also override the Object.hashCode method in order to satisfy the general contract for the Object.hashCodemethod. In particular, c1.equals(c2) implies that c1.hashCode()==c2.hashCode().
Specified by:
hashCode in interface java.util.Collection
Specified by:
hashCode in interface java.util.List
Overrides:
hashCode in class InflatableCollection
Returns:
the hash code value for this collection
See Also:
Object.hashCode(), Object.equals(Object)

add

public void add(int i,
                java.lang.Object o)
Inserts the specified element at the specified position in this list (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
Specified by:
add in interface java.util.List
Parameters:
i - index at which the specified element is to be inserted.
o - element to be inserted.

remove

public java.lang.Object remove(int i)
Removes the element at the specified position in this list (optional operation). Shifts any subsequent elements to the left (subtracts one from their indices). Returns the element that was removed from the list.
Specified by:
remove in interface java.util.List
Parameters:
i - the index of the element to removed.
Returns:
the element previously at the specified position.

addAll

public boolean addAll(int i,
                      java.util.Collection col)
Inserts all of the elements in the specified collection into this list at the specified position (optional operation). Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is unspecified if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)
Specified by:
addAll in interface java.util.List
Parameters:
i - index at which to insert first element from the specified collection.
col - elements to be inserted into this list.
Returns:
true if this list changed as a result of the call.

get

public java.lang.Object get(int i)
Returns the element at the specified position in this list.
Specified by:
get in interface java.util.List
Parameters:
i - index of element to return.
Returns:
the element at the specified position in this list.

indexOf

public 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. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Specified by:
indexOf in interface java.util.List
Parameters:
o - element to search for.
Returns:
the index in this list of the first occurrence of the specified element, or -1 if this list does not contain this element.

lastIndexOf

public 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. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index.
Specified by:
lastIndexOf in interface java.util.List
Parameters:
o - element to search for.
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

public java.util.ListIterator listIterator()
Returns a list iterator of the elements in this list (in proper sequence).
Specified by:
listIterator in interface java.util.List
Returns:
a list iterator of the elements in this list (in proper sequence).

listIterator

public java.util.ListIterator listIterator(int i)
Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to the next method. An initial call to the previous method would return the element with the specified index minus one.
Specified by:
listIterator in interface java.util.List
Parameters:
i - index of first element to be returned from the list iterator (by a call to the next method).
Returns:
a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.

set

public java.lang.Object set(int i,
                            java.lang.Object o)
Replaces the element at the specified position in this list with the specified element (optional operation).
Specified by:
set in interface java.util.List
Parameters:
i - index of element to replace.
o - element to be stored at the specified position.
Returns:
the element previously at the specified position.

subList

public java.util.List subList(int iFrom,
                              int iTo)
Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

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 passing 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 this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

Specified by:
subList in interface java.util.List
Parameters:
iFrom - low endpoint (inclusive) of the subList.
iTo - high endpoint (exclusive) of the subList.
Returns:
a view of the specified range within this list.

instantiateCollection

protected java.util.Collection instantiateCollection()
Factory method used to create a new Collection.
Specified by:
instantiateCollection in class InflatableCollection
Returns:
a "real" implementation to use if this collection is expanded

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.1.0

E18814-01


Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.