SortedMapK,V


SortedMap<K,V> java.util

Java 1.2 collection

This interface represents a Map object that keeps its set of key objects in sorted order. As with Map , it is conventional that all implementations of this interface define a no-argument constructor to create an empty map and a copy constructor that accepts a Map object that specifies the initial contents of the SortedMap . Furthermore, when creating a SortedMap , there should be a way to specify a Comparator object to sort the key objects of the map. If no Comparator is specified, all key objects must implement the java.lang.Comparable interface so they can be sorted in their natural order. See also Map , treeMap , and SortedSet .

The inherited keySet( ) , values( ) , and entrySet( ) methods return collections that can be iterated in the sorted order. firstKey( ) and lastKey( ) return the lowest and highest key values in the SortedMap . subMap( ) returns a SortedMap that contains only mappings for keys from (and including) the first specified key up to (but not including) the second specified key. headMap( ) returns a SortedMap that contains mappings whose keys are less than (but not equal to) the specified key. tailMap( ) returns a SortedMap that contains mappings whose keys are greater than or equal to the specified key. subMap( ) , headMap( ) , and tailMap( ) return SortedMap objects that are simply views of the original SortedMap ; any changes in the original map are reflected in the returned map and vice versa.

Figure 16-56. java.util.SortedMap<K,V>

 public interface  SortedMap<K,V>  extends Map<K,V> {  // Public Instance Methods  Comparator<? super K>  comparator  ( );        K  firstKey  ( );        SortedMap<K,V>  headMap  (K  toKey  );        K  lastKey  ( );        SortedMap<K,V>  subMap  (K  fromKey  , K  toKey  );        SortedMap<K,V>  tailMap  (K  fromKey  );   } 

Implementations

treeMap

Passed To

Collections.{checkedSortedMap( ) , synchronizedSortedMap( ) , unmodifiableSortedMap( )} , treeMap.TreeMap( )

Returned By

java.nio.charset.Charset.availableCharsets( ) , Collections.{checkedSortedMap( ) , synchronizedSortedMap( ) , unmodifiableSortedMap( )} , treeMap.{headMap( ) , subMap( ) , tailMap( )} , java.util.jar.Pack200.Packer.properties( ) , java.util.jar.Pack200.Unpacker.properties( )



Java In A Nutshell
Java In A Nutshell, 5th Edition
ISBN: 0596007736
EAN: 2147483647
Year: 2004
Pages: 1220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net