net.sf.molae.pipe.genimpl
Class SortedKeyProjection<E>

java.lang.Object
  extended by net.sf.molae.pipe.basic.ObjectProxy<B>
      extended by net.sf.molae.pipe.basic.CollectionProxy<B,E>
          extended by net.sf.molae.pipe.basic.SetProxy<Set<E>,E>
              extended by net.sf.molae.pipe.genimpl.KeyProjection<E>
                  extended by net.sf.molae.pipe.genimpl.SortedKeyProjection<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>, SortedSet<E>

public final class SortedKeyProjection<E>
extends KeyProjection<E>
implements SortedSet<E>

Implements a sorted set on an arbitrary sorted map by mapping each set element to a map entry with the set element as key and a dummy element as value of the map.


Constructor Summary
SortedKeyProjection(SortedMap<E,Object> base)
          Constructs a new key projection of the specified map.
 
Method Summary
 Comparator<? super E> comparator()
           
 E first()
          Returns the first (lowest) key currently in the base map.
 SortedSet<E> headSet(E toElement)
           
 E last()
          Returns the last (highest) key currently in the base map.
 SortedSet<E> subSet(E fromElement, E toElement)
           
 SortedSet<E> tailSet(E fromElement)
           
 
Methods inherited from class net.sf.molae.pipe.genimpl.KeyProjection
add, addAll, clear, contains, isEmpty, remove, size
 
Methods inherited from class net.sf.molae.pipe.basic.SetProxy
equals
 
Methods inherited from class net.sf.molae.pipe.basic.CollectionProxy
containsAll, iterator, removeAll, retainAll, toArray, toArray
 
Methods inherited from class net.sf.molae.pipe.basic.ObjectProxy
assertNotNull, getBase, hashCode, toString, toVerboseString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Constructor Detail

SortedKeyProjection

public SortedKeyProjection(SortedMap<E,Object> base)
Constructs a new key projection of the specified map.

Parameters:
base - The base map of this set. The map may contain entries, but must not contain null values.
Method Detail

comparator

public Comparator<? super E> comparator()
Specified by:
comparator in interface SortedSet<E>

subSet

public SortedSet<E> subSet(E fromElement,
                           E toElement)
Specified by:
subSet in interface SortedSet<E>
Throws:
ClassCastException - depending on the base map
IllegalArgumentException - depending on the base map
NullPointerException - depending on the base map

headSet

public SortedSet<E> headSet(E toElement)
Specified by:
headSet in interface SortedSet<E>
Throws:
ClassCastException - depending on the base map
IllegalArgumentException - depending on the base map
NullPointerException - depending on the base map

tailSet

public SortedSet<E> tailSet(E fromElement)
Specified by:
tailSet in interface SortedSet<E>
Throws:
ClassCastException - depending on the base map
IllegalArgumentException - depending on the base map
NullPointerException - depending on the base map

first

public E first()
Returns the first (lowest) key currently in the base map.

Specified by:
first in interface SortedSet<E>
Returns:
the first (lowest) key currently in the base map.
Throws:
NoSuchElementException - base map is empty.

last

public E last()
Returns the last (highest) key currently in the base map.

Specified by:
last in interface SortedSet<E>
Returns:
the last (highest) key currently in the base map.
Throws:
NoSuchElementException - base map is empty.