org.geotools.resources
Class LazySet<E>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractSet<E>
          extended by org.geotools.resources.LazySet<E>
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>, java.util.Set<E>

public final class LazySet<E>
extends java.util.AbstractSet<E>

An immutable set built from an iterator, which will be filled only when needed. This implementation do not check if all elements in the iterator are really unique; we assume that it was already verified by ServiceRegistry. This set is constructed by org.geotools.referencing.FactoryFinder.

Since:
2.0
Version:
$Id: LazySet.java 30640 2008-06-12 17:34:32Z acuster $
Author:
Martin Desruisseaux (IRD)

Constructor Summary
LazySet(java.util.Iterator<? extends E> iterator)
          Construct a set to be filled using the specified iterator.
 
Method Summary
 E get(int index)
          Returns the element at the specified position in this set.
 boolean isEmpty()
          Tests if this set has no elements.
 java.util.Iterator<E> iterator()
          Returns an iterator over the elements contained in this set.
 int size()
          Returns the number of elements in this set.
 
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
 
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, contains, containsAll, remove, 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.Set
add, addAll, clear, contains, containsAll, remove, retainAll, toArray, toArray
 

Constructor Detail

LazySet

public LazySet(java.util.Iterator<? extends E> iterator)
Construct a set to be filled using the specified iterator. Iteration in the given iterator will occurs only when needed.

Method Detail

iterator

public java.util.Iterator<E> iterator()
Returns an iterator over the elements contained in this set. This is not the same iterator than the one given to the constructor.

Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>
Specified by:
iterator in interface java.util.Set<E>
Specified by:
iterator in class java.util.AbstractCollection<E>

size

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

Specified by:
size in interface java.util.Collection<E>
Specified by:
size in interface java.util.Set<E>
Specified by:
size in class java.util.AbstractCollection<E>

isEmpty

public boolean isEmpty()
Tests if this set has no elements.

Specified by:
isEmpty in interface java.util.Collection<E>
Specified by:
isEmpty in interface java.util.Set<E>
Overrides:
isEmpty in class java.util.AbstractCollection<E>

get

public E get(int index)
Returns the element at the specified position in this set.



Copyright © 1996-2010 Geotools. All Rights Reserved.