org.geotoolkit.util.collection
Class LazyList<E>
Object
AbstractCollection<E>
AbstractList<E>
AbstractSequentialList<E>
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:
|
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. |
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.
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.