Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


com.tangosol.util
Class WrapperCollections.AbstractWrapperList

java.lang.Object
  extended by com.tangosol.util.WrapperCollections.AbstractWrapperCollection
      extended by com.tangosol.util.WrapperCollections.AbstractWrapperList

All Implemented Interfaces:
Iterable, Collection, List
Direct Known Subclasses:
ImmutableArrayList.ListView, ImmutableMultiList.ListView
Enclosing class:
WrapperCollections

public abstract static class WrapperCollections.AbstractWrapperList
extends WrapperCollections.AbstractWrapperCollection
implements List

List implementation which delegates all calls to another List.


Field Summary

 

Fields inherited from class com.tangosol.util.WrapperCollections.AbstractWrapperCollection
m_colDelegate

 

Constructor Summary
protected WrapperCollections.AbstractWrapperList(List list)
          Create an AbstractWrapperList which delegates to the specified List.

 

Method Summary
 void add(int index, Object element)
          Inserts the specified element at the specified position in this list (optional operation).
 boolean addAll(int index, Collection c)
          Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
 Object get(int index)
          Returns the element at the specified position in this list.
protected  List getDelegate()
          Return the List to which all operations should be delegated to.
 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.
 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 a list iterator of the elements in this list (in proper sequence).
 ListIterator listIterator(int index)
          Returns a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list.
 Object remove(int index)
          Removes the element at the specified position in this list (optional operation).
 Object set(int index, Object element)
          Replaces the element at the specified position in this list with the specified element (optional operation).
 List subList(int fromIndex, int toIndex)
          Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.

 

Methods inherited from class com.tangosol.util.WrapperCollections.AbstractWrapperCollection
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray

 

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

 

Constructor Detail

WrapperCollections.AbstractWrapperList

protected WrapperCollections.AbstractWrapperList(List list)
Create an AbstractWrapperList which delegates to the specified List.
Parameters:
list - the List to delegate all calls to

Method Detail

getDelegate

protected List getDelegate()
Return the List to which all operations should be delegated to.
Overrides:
getDelegate in class WrapperCollections.AbstractWrapperCollection
Returns:
the wrapped List

addAll

public boolean addAll(int index,
                      Collection c)
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 List
Parameters:
index - index at which to insert first element from the specified collection.
c - elements to be inserted into this list.
Returns:
true if this list changed as a result of the call.

get

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

set

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

add

public void add(int index,
                Object element)
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 List
Parameters:
index - index at which the specified element is to be inserted.
element - element to be inserted.

remove

public Object remove(int index)
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 List
Parameters:
index - the index of the element to removed.
Returns:
the element previously at the specified position.

indexOf

public 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. 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 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(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 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 ListIterator listIterator()
Returns a list iterator of the elements in this list (in proper sequence).
Specified by:
listIterator in interface List
Returns:
a list iterator of the elements in this list (in proper sequence).

listIterator

public ListIterator listIterator(int index)
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 List
Parameters:
index - 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.

subList

public List subList(int fromIndex,
                    int toIndex)
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 List
Parameters:
fromIndex - low endpoint (inclusive) of the subList.
toIndex - high endpoint (exclusive) of the subList.
Returns:
a view of the specified range within this list.

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.6.0.0

E15725-01


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