info.aduna.collections
Class ListView<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<E>
              extended by info.aduna.collections.ListView<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>

public class ListView<E>
extends AbstractSequentialList<E>

ListView represents an immutable view on another list, which is also assumed to be immutable. As a result of this, iterators on instances of this class do NOT support the (optional) modification operations.


Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Method Summary
static
<E> ListView<E>
createView(List<E> listToView, BitSet viewedIndices)
           
 ListIterator<E> listIterator(int index)
          Get an iterator over this view.
 int size()
          The size of the view.
 
Methods inherited from class java.util.AbstractSequentialList
add, addAll, get, iterator, remove, set
 
Methods inherited from class java.util.AbstractList
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Method Detail

createView

public static <E> ListView<E> createView(List<E> listToView,
                                         BitSet viewedIndices)

listIterator

public ListIterator<E> listIterator(int index)
Get an iterator over this view. Note that this iterator is NOT fail-fast and does not monitor changes in the underlying list. Also note that backwards iteration is likely to be significantly slower than forwards iteration on large lists. The iterator supports none of optional modification methods.

Specified by:
listIterator in interface List<E>
Specified by:
listIterator in class AbstractSequentialList<E>
Returns:
an iterator over this view

size

public int size()
The size of the view. Note that since the underlying list is assumed to be immutable, the size will remain constant even when the underlying list or the viewed indices change.

Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>
Returns:
the number of elements in this view


Copyright © 1997-2008 Aduna. All Rights Reserved.