net.sf.molae.pipe.genimpl
Class SortedListAsSortedSet<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.CollectionAsSet<B,E>
              extended by net.sf.molae.pipe.sorted.SetAsSortedSet<Set<E>,E>
                  extended by net.sf.molae.pipe.genimpl.SortedListAsSortedSet<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, Set<E>, SortedSet<E>

public class SortedListAsSortedSet<E>
extends SetAsSortedSet<Set<E>,E>

Sorted list backed implementation of the SortedSet interface.


Nested Class Summary
protected static class SortedListAsSortedSet.SortedListAsSet<E>
          Sorted list backed implementation of the Set interface.
 
Constructor Summary
SortedListAsSortedSet()
          Creates a new sorted set based on a Vector and natural ordering.
SortedListAsSortedSet(List<E> base)
          Creates a new sorted list based sorted set with the specified base list and natural ordering.
SortedListAsSortedSet(List<E> base, Comparator<? super E> comparator)
          Creates a new sorted list based sorted set with the specified base list and comparator.
 
Method Summary
 E first()
          Returns the first (lowest) element currently in this sorted set.
protected  List<E> getList()
          Returns the backing list of this sorted set.
 E last()
          Returns the last (highest) element currently in this sorted set.
static
<E extends Comparable<? super E>>
SortedSet<E>
newInstance(Collection<? extends E> c)
          Creates a new sorted set based on a Vector and natural ordering containing the elements in the specified collection.
 
Methods inherited from class net.sf.molae.pipe.sorted.SetAsSortedSet
comparator, compare, containsAll, getBoundComparator, getFromElement, getSubSet, getToElement, headSet, newInstance, removeAll, retainAll, setConsistent, subSet, tailSet, useMerge
 
Methods inherited from class net.sf.molae.pipe.basic.CollectionAsSet
equals, hashCode, isSet, newInstance
 
Methods inherited from class net.sf.molae.pipe.basic.CollectionProxy
add, addAll, clear, contains, isEmpty, iterator, remove, size, toArray, toArray
 
Methods inherited from class net.sf.molae.pipe.basic.ObjectProxy
assertNotNull, getBase, toString, toVerboseString
 
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, equals, hashCode, isEmpty, iterator, remove, size, toArray, toArray
 

Constructor Detail

SortedListAsSortedSet

public SortedListAsSortedSet(List<E> base,
                             Comparator<? super E> comparator)
Creates a new sorted list based sorted set with the specified base list and comparator.

Parameters:
base - the list where the set elements are stored. If the list is not empty its elements must be sorted by the specified comparator
comparator - determines the sorting in the base list
Throws:
NullPointerException - if the specified list is null.

SortedListAsSortedSet

public SortedListAsSortedSet(List<E> base)
Creates a new sorted list based sorted set with the specified base list and natural ordering.

Parameters:
base - the list where the set elements are stored. If the list is not empty its elements must be sorted.
Throws:
NullPointerException - if the specified list is null.

SortedListAsSortedSet

public SortedListAsSortedSet()
Creates a new sorted set based on a Vector and natural ordering.

Method Detail

getList

protected final List<E> getList()
Returns the backing list of this sorted set.

Returns:
the backing list of this sorted set

newInstance

public static <E extends Comparable<? super E>> SortedSet<E> newInstance(Collection<? extends E> c)
Creates a new sorted set based on a Vector and natural ordering containing the elements in the specified collection.

Parameters:
c - the collection whose elements are to be placed into this set.

first

public E first()
Returns the first (lowest) element currently in this sorted set.

Specified by:
first in interface SortedSet<E>
Overrides:
first in class SetAsSortedSet<Set<E>,E>
Returns:
the first (lowest) element currently in this sorted set.
Throws:
NoSuchElementException - sorted set is empty.

last

public E last()
Returns the last (highest) element currently in this sorted set.

Specified by:
last in interface SortedSet<E>
Overrides:
last in class SetAsSortedSet<Set<E>,E>
Returns:
the last (highest) element currently in this sorted set.
Throws:
NoSuchElementException - sorted set is empty.