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

public class ListAsSortedSet<B extends List<E>,E>
extends SetAsSortedSet<B,E>

Sorted list backed implementation of the SortedSet interface.


Constructor Summary
  ListAsSortedSet(B base, Comparator<? super E> comparator)
          Constructs a ListAsSortedSet object.
protected ListAsSortedSet(B base, Comparator<? super E> comparator, Comparator<Bound<E>> boundComparator, Bound<E> fromElement, Bound<E> toElement)
          Creates a new ListAsSortedSet with the specified properties.
 
Method Summary
 E first()
          Returns the first (lowest) element currently in this sorted set.
 E last()
          Returns the last (highest) element currently in this sorted set.
 
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

ListAsSortedSet

public ListAsSortedSet(B base,
                       Comparator<? super E> comparator)
Constructs a ListAsSortedSet object.

Parameters:
base - the underlying list
comparator - the comparator that will be used to sort this set. A null value indicates that the elements' natural ordering should be used.

ListAsSortedSet

protected ListAsSortedSet(B base,
                          Comparator<? super E> comparator,
                          Comparator<Bound<E>> boundComparator,
                          Bound<E> fromElement,
                          Bound<E> toElement)
Creates a new ListAsSortedSet with the specified properties. This constructor is intended for classes that implement both the SortedSet and its subsets.

Parameters:
base - the underlying list
comparator - the comparator that will be used to sort this set. A null value indicates that the elements' natural ordering should be used.
boundComparator - the comparator that will be used to compare bounds - used for subsets
fromElement - low endpoint (inclusive) of the subSet
toElement - high endpoint (exclusive) of the subSet
Throws:
ClassCastException - if FromElement and toElement cannot be compared to one another using this set's comparator (or, if the set has no comparator, using natural ordering).
IllegalArgumentException - if fromElement is greater than toElement.
NullPointerException - if fromElement or toElement is null and this set uses natural order, or its comparator does not tolerate null elements or if the base set is null.
Method Detail

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<B extends List<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<B extends List<E>,E>
Returns:
the last (highest) element currently in this sorted set.
Throws:
NoSuchElementException - sorted set is empty.