net.sf.molae.pipe.genimpl
Class SortedListAsSortedMap<K,V>

java.lang.Object
  extended by net.sf.molae.pipe.basic.ObjectProxy<B>
      extended by net.sf.molae.pipe.basic.MapProxy<B,K,V>
          extended by net.sf.molae.pipe.sorted.MapAsSortedMap<Map<K,V>,K,V>
              extended by net.sf.molae.pipe.genimpl.SortedListAsSortedMap<K,V>
All Implemented Interfaces:
Map<K,V>, SortedMap<K,V>

public class SortedListAsSortedMap<K,V>
extends MapAsSortedMap<Map<K,V>,K,V>

Sorted list backed implementation of the SortedMap interface.

See Also:
SortedListAsSortedSet

Nested Class Summary
protected static class SortedListAsSortedMap.SortedListAsMap<K,V>
          Sorted list backed implementation of the Map interface.
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Constructor Summary
  SortedListAsSortedMap()
          Creates a new sorted map based on a Vector with natural ordering.
protected SortedListAsSortedMap(List<Map.Entry<K,V>> base)
          Creates a new sorted list based sorted map with the specified base list and natural ordering.
protected SortedListAsSortedMap(List<Map.Entry<K,V>> base, Comparator<? super K> comparator)
          Creates a new sorted list based sorted map with the specified base list and comparator.
  SortedListAsSortedMap(Map<K,V> t)
          Creates a new sorted map based on a Vector with the same mappings as the given map.
 
Method Summary
 K firstKey()
          Returns the first (lowest) key currently in this sorted map.
protected  List<Map.Entry<K,V>> getList()
          Returns the backing list of this sorted map.
 K lastKey()
          Returns the last (highest) key currently in this sorted map.
 
Methods inherited from class net.sf.molae.pipe.sorted.MapAsSortedMap
comparator, compare, getBoundComparator, getFromKey, getSubMap, getToKey, headMap, newInstance, subMap, tailMap
 
Methods inherited from class net.sf.molae.pipe.basic.MapProxy
clear, containsKey, containsValue, entrySet, equals, get, isEmpty, keySet, put, putAll, remove, size, values
 
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, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.SortedMap
entrySet, keySet, values
 
Methods inherited from interface java.util.Map
clear, containsKey, containsValue, equals, get, hashCode, isEmpty, put, putAll, remove, size
 

Constructor Detail

SortedListAsSortedMap

protected SortedListAsSortedMap(List<Map.Entry<K,V>> base,
                                Comparator<? super K> comparator)
Creates a new sorted list based sorted map with the specified base list and comparator.

Parameters:
base - the list where the map entries are stored. If the list is not empty its keys must be sorted by the specified comparator
comparator - determines the sorting in the base list
Throws:
NullPointerException - if the specified list is null.
ClassCastException - if the list contains elements that are not mutually comparable

SortedListAsSortedMap

protected SortedListAsSortedMap(List<Map.Entry<K,V>> base)
Creates a new sorted list based sorted map with the specified base list and natural ordering.

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

SortedListAsSortedMap

public SortedListAsSortedMap()
Creates a new sorted map based on a Vector with natural ordering.


SortedListAsSortedMap

public SortedListAsSortedMap(Map<K,V> t)
Creates a new sorted map based on a Vector with the same mappings as the given map.

Parameters:
t - the map whose mappings are to be placed in this map.
Method Detail

getList

protected final List<Map.Entry<K,V>> getList()
Returns the backing list of this sorted map.

Returns:
the backing list of this sorted map

firstKey

public K firstKey()
Returns the first (lowest) key currently in this sorted map.

Specified by:
firstKey in interface SortedMap<K,V>
Overrides:
firstKey in class MapAsSortedMap<Map<K,V>,K,V>
Returns:
the first (lowest) key currently in this sorted map.
Throws:
NoSuchElementException - if this map is empty.

lastKey

public K lastKey()
Returns the last (highest) key currently in this sorted map.

Specified by:
lastKey in interface SortedMap<K,V>
Overrides:
lastKey in class MapAsSortedMap<Map<K,V>,K,V>
Returns:
the last (highest) key currently in this sorted map.
Throws:
NoSuchElementException - if this map is empty.