org.geotoolkit.util.collection
Class LazyList<E>

Object
  extended by AbstractCollection<E>
      extended by AbstractList<E>
          extended by AbstractSequentialList<E>
              extended by LazyList<E>
Type Parameters:
E - The type of elements in the list.
All Implemented Interfaces:
Iterable<E>, Collection<E>, List<E>

public class LazyList<E>
extends AbstractSequentialList<E>

An immutable list filled when needed from the values returned by an iterator.

Since:
2.0
Version:
3.00
Author:
Martin Desruisseaux (IRD)
Module:
utility/geotk-utility (download)    View source code for this class

Field Summary
 
Fields inherited from class AbstractList
modCount
 
Constructor Summary
LazyList(Iterator<? extends E> iterator)
          Constructs a list to be filled using the specified iterator.
 
Method Summary
 E get(int index)
          Returns the element at the specified position in this list.
 boolean isEmpty()
          Returns true if this list has no elements.
 ListIterator<E> listIterator(int index)
          Returns an iterator over the elements in this list.
 int size()
          Returns the number of elements in this list.
 
Methods inherited from class AbstractSequentialList
add, addAll, iterator, remove, set
 
Methods inherited from class AbstractList
add, clear, equals, hashCode, indexOf, lastIndexOf, listIterator, removeRange, subList
 
Methods inherited from class AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface List
addAll, contains, containsAll, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

LazyList

public LazyList(Iterator<? extends E> iterator)
Constructs a list to be filled using the specified iterator. Iteration will occurs only when needed.

Parameters:
iterator - The iterator to use for filling this list.
Method Detail

isEmpty

public final boolean isEmpty()
Returns true if this list has no elements.

Specified by:
isEmpty in interface Collection<E>
Specified by:
isEmpty in interface List<E>
Overrides:
isEmpty in class AbstractCollection<E>

size

public final int size()
Returns the number of elements in this list. Invoking this method force the set to immediately iterates through all remaining elements.

Specified by:
size in interface Collection<E>
Specified by:
size in interface List<E>
Specified by:
size in class AbstractCollection<E>

get

public final E get(int index)
            throws IndexOutOfBoundsException
Returns the element at the specified position in this list.

Specified by:
get in interface List<E>
Overrides:
get in class AbstractSequentialList<E>
Parameters:
index - The index at which to obtain an element.
Returns:
The element at the given index.
Throws:
IndexOutOfBoundsException - If the given index is out of bounds.

listIterator

public ListIterator<E> listIterator(int index)
                             throws IndexOutOfBoundsException
Returns an iterator over the elements in this list.

Specified by:
listIterator in interface List<E>
Specified by:
listIterator in class AbstractSequentialList<E>
Parameters:
index - Index of first element to be returned from the iterator.
Returns:
An iterator over the elements in this list.
Throws:
IndexOutOfBoundsException - If the given index is out of bounds.


Copyright © 2009-2013 Geotoolkit.org. All Rights Reserved.