java.util

Class TreeMap<K,V>

Implemented Interfaces:
Cloneable, Map<K,V>, Serializable, SortedMap<K,V>
Known Direct Subclasses:
FastTreeMap

public class TreeMap<K,V>
extends AbstractMap<K,V>
implements SortedMap<K,V>, Cloneable, Serializable

Red-Black tree based implementation of the SortedMap interface. This class guarantees that the map will be in ascending key order, sorted according to the natural order for the key's class (see Comparable), or by the comparator provided at creation time, depending on which constructor is used.

This implementation provides guaranteed log(n) time cost for the containsKey, get, put and remove operations. Algorithms are adaptations of those in Cormen, Leiserson, and Rivest's Introduction to Algorithms.

Note that the ordering maintained by a sorted map (whether or not an explicit comparator is provided) must be consistent with equals if this sorted map is to correctly implement the Map interface. (See Comparable or Comparator for a precise definition of consistent with equals.) This is so because the Map interface is defined in terms of the equals operation, but a map performs all key comparisons using its compareTo (or compare) method, so two keys that are deemed equal by this method are, from the standpoint of the sorted map, equal. The behavior of a sorted map is well-defined even if its ordering is inconsistent with equals; it just fails to obey the general contract of the Map interface.

Note that this implementation is not synchronized. If multiple threads access a map concurrently, and at least one of the threads modifies the map structurally, it must be synchronized externally. (A structural modification is any operation that adds or deletes one or more mappings; merely changing the value associated with an existing key is not a structural modification.) This is typically accomplished by synchronizing on some object that naturally encapsulates the map. If no such object exists, the map should be "wrapped" using the Collections.synchronizedMap method. This is best done at creation time, to prevent accidental unsynchronized access to the map:

     Map m = Collections.synchronizedMap(new TreeMap(...));
 

The iterators returned by all of this class's "collection view methods" are fail-fast: if the map is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove or add methods, the iterator throws a ConcurrentModificationException. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.

Note that the fail-fast behavior of an iterator cannot be guaranteed as it is, generally speaking, impossible to make any hard guarantees in the presence of unsynchronized concurrent modification. Fail-fast iterators throw ConcurrentModificationException on a best-effort basis. Therefore, it would be wrong to write a program that depended on this exception for its correctness: the fail-fast behavior of iterators should be used only to detect bugs.

This class is a member of the ../../../guide/collections/index.html"> Java Collections Framework.

Since:
1.2
See Also:
Map, HashMap, Hashtable, Comparable, Comparator, Collection, Collections.synchronizedMap(Map), Serialized Form

Constructor Summary

TreeMap()
Constructs a new, empty map, sorted according to the keys' natural order.
TreeMap(K> c)
Constructs a new, empty map, sorted according to the given comparator.
TreeMap(SortedMap m)
Constructs a new map containing the same mappings as the given SortedMap, sorted according to the same ordering.
TreeMap(extends K, V> m)
Constructs a new map containing the same mappings as the given map, sorted according to the keys' natural order.

Method Summary

void
clear()
Removes all mappings from this TreeMap.
Object
clone()
Returns a shallow copy of this TreeMap instance.
boolean
containsKey(Object key)
Returns true if this map contains a mapping for the specified key.
boolean
containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
Set>
entrySet()
Returns a set view of the mappings contained in this map.
K
firstKey()
Returns the first (lowest) key currently in this sorted map.
V
get(Object key)
Returns the value to which this map maps the specified key.
SortedMap
headMap(K toKey)
Returns a view of the portion of this map whose keys are strictly less than toKey.
Set
keySet()
Returns a Set view of the keys contained in this map.
K
lastKey()
Returns the last (highest) key currently in this sorted map.
V
put(K key, V value)
Associates the specified value with the specified key in this map.
void
putAll(extends K, V> map)
Copies all of the mappings from the specified map to this map.
V
remove(Object key)
Removes the mapping for this key from this TreeMap if present.
int
size()
Returns the number of key-value mappings in this map.
SortedMap
subMap(K fromKey, K toKey)
Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
Comparator
super K> comparator()
Returns the comparator used to order this map, or null if this map uses its keys' natural order.
SortedMap
tailMap(K fromKey)
Returns a view of the portion of this map whose keys are greater than or equal to fromKey.
Collection
values()
Returns a collection view of the values contained in this map.

Methods inherited from class java.util.AbstractMap<K,V>

clear, clone, containsKey, containsValue, entrySet, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Details

TreeMap

public TreeMap()
Constructs a new, empty map, sorted according to the keys' natural order. All keys inserted into the map must implement the Comparable interface. Furthermore, all such keys must be mutually comparable: k1.compareTo(k2) must not throw a ClassCastException for any elements k1 and k2 in the map. If the user attempts to put a key into the map that violates this constraint (for example, the user attempts to put a string key into a map whose keys are integers), the put(Object key, Object value) call will throw a ClassCastException.
See Also:
Comparable
Usages and Demos :

View More Examples of TreeMap()
   1:     test(new HashMap(), 10);
   2:     test(new TreeMap(), 10);
   3:     test(new Hashtable(), 100);
   4:         ...
   5:     test(new HashMap(), 100);
   6:     test(new TreeMap(), 100);
   7:     test(new HashMap(), 1000);
   8:         ...
   9:     test(new Hashtable(), 1000);
  10:     test(new TreeMap(), 1000);
  11:   }

View Full Code Here
   1:       m.containsValue(hodnota)); 
   2:     Map m2 = new TreeMap();
   3:     Collections2.fill(m2, rsp, 25);
   4:         ...
   5:     System.out.println("Testovani kontejneru TreeMap");
   6:     test(new TreeMap());
   7:   }

View Full Code Here
   1:       m.containsValue(value)); 
   2:     Map m2 = fill(new TreeMap(), testData2);
   3:     m.putAll(m2);
   4:         ...
   5:     System.out.println("Testing TreeMap");
   6:     test(new TreeMap());
   7:   }

View Full Code Here
   1:     public Map makeEmptyMap() {
   2:         return FixedSizeSortedMap.decorate(new TreeMap());
   3:     }
   4:         ...
   5:     public Map makeFullMap() {
   6:         SortedMap map = new TreeMap();
   7:         addSampleMappings(map);
   8:         return FixedSizeSortedMap.decorate(map);
   9:     }

View Full Code Here
   1:         beans.add(new HashMap());
   2:         beans.add(new TreeMap());
   3:         return beans;
   4:     }

View Full Code Here

TreeMap

public TreeMap(K> c)
Constructs a new, empty map, sorted according to the given comparator. All keys inserted into the map must be mutually comparable by the given comparator: comparator.compare(k1, k2) must not throw a ClassCastException for any keys k1 and k2 in the map. If the user attempts to put a key into the map that violates this constraint, the put(Object key, Object value) call will throw a ClassCastException.
Parameters:
c - the comparator that will be used to sort this map. A null value indicates that the keys' natural ordering should be used.
Usages and Demos :

View More Examples of TreeMap(K> c)
   1:         String c = "c";
   2:         Map longMap = new TreeMap(Comparators.longComparator());
   3:         java.util.Map referenceLongMap = new java.util.TreeMap();
   4:         ...
   5:         String c = "c";
   6:         Map longMap = new TreeMap(Comparators.inverseLongComparator());
   7:         longMap.put(one, a);
   8:         longMap.put(two, b);
   9:         longMap.put(three, c);

View Full Code Here
   1:   {
   2:    underlyingTreeMap = new TreeMap(_statementComparator);
   3:    _indexesToTreemapsOfStatements.put(index, underlyingTreeMap);
   4:   }
   5:   StatementWrapper wrapper = new StatementWrapper(index, value);

View Full Code Here
   1:   {
   2:     map = new TreeMap(NameComponentComparator.singleton);
   3:   }
   4: 
   5:   public void bind(NameComponent name, org.omg.CORBA.Object object)

View Full Code Here
   1:     {
   2:         components = new TreeMap(Location.naturalOrder);
   3:         componentList = new ArrayList();
   4:     }

View Full Code Here
   1:                 String[] sysfonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
   2:                 currentFonts = new TreeMap(StringUtil.CASE_INSENSITIVE_COMPARATOR);
   3:                 for (int i=0; i<sysfonts.length; i++)
   4:             }
   5:         }

View Full Code Here

TreeMap

public TreeMap(SortedMap m)
Constructs a new map containing the same mappings as the given SortedMap, sorted according to the same ordering. This method runs in linear time.
Parameters:
m - the sorted map whose mappings are to be placed in this map, and whose comparator is to be used to sort this map.
Throws:
NullPointerException - if the specified sorted map is null.
Usages and Demos :

View More Examples of TreeMap(SortedMap m)
   1: 
   2:     public TreeMap(Map<A,B> m) {
   3:     putAll(m);
   4:         ...
   5: 
   6:     public TreeMap(SortedMap<A,B> m) {
   7:         comparator = m.comparator();
   8:     }

View Full Code Here

TreeMap

public TreeMap(extends K,
               V> m)
Constructs a new map containing the same mappings as the given map, sorted according to the keys' natural order. All keys inserted into the new map must implement the Comparable interface. Furthermore, all such keys must be mutually comparable: k1.compareTo(k2) must not throw a ClassCastException for any elements k1 and k2 in the map. This method runs in n*log(n) time.
Parameters:
m - the map whose mappings are to be placed in this map.
Throws:
ClassCastException - the keys in t are not Comparable, or are not mutually comparable.
NullPointerException - if the specified map is null.
Usages and Demos :

View More Examples of TreeMap(extends K,V> m)
   1: 
   2:     public TreeMap(Map<A,B> m) {
   3:     putAll(m);
   4:         ...
   5: 
   6:     public TreeMap(SortedMap<A,B> m) {
   7:         comparator = m.comparator();
   8:     }

View Full Code Here

Method Details

clear

public void clear()
Removes all mappings from this TreeMap.
Specified by:
clear in interface Map<K,V>
Overrides:
clear in interface AbstractMap<K,V>
Usages and Demos :

View More Examples of clear()
   1: 
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: public class UUIDProvider implements ConfigurationProvider {
   6:     private TreeMap nameToUUID = new TreeMap();
   7:     private TreeMap uuidToName = new TreeMap();
   8:         ...
   9:     public synchronized void reset() {
  10:         nameToUUID.clear();
  11:         ...
  12:         uuidToName.clear();

View Full Code Here
   1: 
   2: import java.util.TreeMap;
   3: import java.util.Iterator;
   4:         ...
   5:     
   6:     protected TreeMap map = new TreeMap();
   7:     protected long lastAccess = 0;
   8:         ...
   9:         LOG.debug("cleaning up element pool ..");
  10:         map.clear();
  11:     }
  12:         ...
  13:         if(System.currentTimeMillis() - lastAccess > TIMEOUT)
  14:             map.clear();

View Full Code Here
   1: import java.util.Comparator;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:     private void init() {
   6:         fCatMap = new TreeMap(new Comparator() {
   7:             public int compare(Object arg0, Object arg1) {
   8:         ...
   9:         });
  10:         fConMap = new TreeMap();
  11:         Command[] commands = fComServ.getDefinedCommands();
  12:         ...
  13:     public void dispose() {
  14:         fCatMap.clear();

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:   protected String id;
   6:   private TreeMap registeredHandlers = new TreeMap();
   7: 
   8:         ...
   9:   {
  10:     registeredHandlers.clear();
  11:   }

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:     private String name = "multi";
   6:     private TreeMap containers = new TreeMap();
   7: 
   8:         ...
   9:         }
  10:         containers.clear();
  11:         containers = null;

View Full Code Here

clone

public Object clone()
Returns a shallow copy of this TreeMap instance. (The keys and values themselves are not cloned.)
Overrides:
clone in interface AbstractMap<K,V>
Returns:
a shallow copy of this Map.
Usages and Demos :

View More Examples of clone()
   1: import java.util.Iterator;
   2: import java.util.TreeMap;
   3: import org.rcosjava.messaging.messages.AddHandler;
   4:         ...
   5: 
   6:   private TreeMap registeredHandlers = new TreeMap();
   7: 
   8:         ...
   9:     {
  10:       return (TreeMap) registeredHandlers.clone();
  11:     }

View Full Code Here
   1: import java.util.ResourceBundle;
   2: import java.util.TreeMap;
   3: import java.util.Vector;
   4:         ...
   5: 
   6:     public TreeMap map;
   7:     public Vector intervals;
   8:         ...
   9:     public Object clone() throws CloneNotSupportedException {
  10:         GenericMapper m = (GenericMapper)super.clone();
  11:         ...
  12:         m.map = (TreeMap)map.clone();

View Full Code Here

containsKey

public boolean containsKey(Object key)
Returns true if this map contains a mapping for the specified key.
Specified by:
containsKey in interface Map<K,V>
Overrides:
containsKey in interface AbstractMap<K,V>
Parameters:
key - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.
Throws:
ClassCastException - if the key cannot be compared with the keys currently in the map.
NullPointerException - key is null and this map uses natural ordering, or its comparator does not tolerate null keys.
Usages and Demos :

View More Examples of containsKey(Object key)
   1: import java.io.InputStreamReader;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   private TreeMap languages;
   7: 
   8:         ...
   9:   {
  10:     languages = new TreeMap();
  11:   }
  12:         ...
  13:   {
  14:     return languages.containsKey(c);

View Full Code Here
   1: import java.io.InputStreamReader;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   private TreeMap countries;
   7: 
   8:         ...
   9:   {
  10:     countries = new TreeMap();
  11:   }
  12:         ...
  13:   {
  14:     return countries.containsKey(c);

View Full Code Here
   1: import java.util.List;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: 
   6:   final TreeMap atts_ = new TreeMap();
   7:   final TObjectIntHashMap attUsed_ = new TObjectIntHashMap();
   8:         ...
   9:   public boolean contains(String _name){
  10:     return atts_.containsKey(_name);
  11:   }

View Full Code Here
   1: import java.util.Set;
   2: import java.util.TreeMap;
   3: import java.util.NoSuchElementException;
   4:         ...
   5: {
   6:   TreeMap roots = new TreeMap();
   7:   HashMap entries = new HashMap();
   8:         ...
   9:   public boolean isRegistered(String name){
  10:     return roots.containsKey(name);
  11:   }

View Full Code Here
   1: import java.util.Map;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   private TreeMap threads = new TreeMap();
   7: 
   8:         ...
   9:       {
  10:         return threads.containsKey(t.getName());
  11:       }

View Full Code Here

containsValue

public boolean containsValue(Object value)
Returns true if this map maps one or more keys to the specified value. More formally, returns true if and only if this map contains at least one mapping to a value v such that (value==null ? v==null : value.equals(v)). This operation will probably require time linear in the Map size for most implementations of Map.
Specified by:
containsValue in interface Map<K,V>
Overrides:
containsValue in interface AbstractMap<K,V>
Parameters:
value - value whose presence in this Map is to be tested.
Returns:
true if a mapping to value exists; false otherwise.
Since:
1.2
Usages and Demos :

View More Examples of containsValue(Object value)
   1: import java.io.InputStreamReader;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   private TreeMap languages;
   7: 
   8:         ...
   9:   {
  10:     languages = new TreeMap();
  11:   }
  12:         ...
  13:   {
  14:     return languages.containsValue(c);

View Full Code Here
   1: import java.io.InputStreamReader;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   private TreeMap countries;
   7: 
   8:         ...
   9:   {
  10:     countries = new TreeMap();
  11:   }
  12:         ...
  13:   {
  14:     return countries.containsValue(c);

View Full Code Here
   1: import java.util.Set;
   2: import java.util.TreeMap;
   3: import java.util.NoSuchElementException;
   4:         ...
   5: {
   6:   TreeMap roots = new TreeMap();
   7:   HashMap entries = new HashMap();
   8:         ...
   9:   private boolean containsRoot(File root){
  10:     return roots.containsValue(root);
  11:   }

View Full Code Here
   1: import java.util.Set;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   protected final TreeMap map;
   7: 
   8:         ...
   9:   {
  10:     map = new TreeMap(NameComponentComparator.singleton);
  11:   }
  12:         ...
  13:   {
  14:     return map.containsValue(object);

View Full Code Here

entrySet

public Set> entrySet()
Returns a set view of the mappings contained in this map. The set's iterator returns the mappings in ascending key order. Each element in the returned set is a Map.Entry. The set is backed by this map, so changes to this map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from the TreeMap, through the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.
Overrides:
entrySet in interface AbstractMap<K,V>
Returns:
a set view of the mappings contained in this map.
See Also:
Map.Entry
Usages and Demos :

View More Examples of entrySet()
   1: import java.util.Set;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   protected final TreeMap map;
   7: 
   8:         ...
   9:   {
  10:     map = new TreeMap(NameComponentComparator.singleton);
  11:   }
  12:         ...
  13:   {
  14:     return map.entrySet();

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:                 
   6:         TreeMap tempTables = new TreeMap();
   7:         int j = 1;
   8:         ...
   9:         TreeMap sorter = new TreeMap();
  10:         while (tempTables.entrySet().size() > 1) {
  11:             Table tempTable = Catalog.getInstance().getBlankTable();

View Full Code Here
   1: import jp.ujihara.java.util.Map;
   2: import jp.ujihara.java.util.TreeMap;
   3: 
   4:         ...
   5:   {
   6:     layers = new TreeMap ();
   7:     componentToLayer = new Hashtable ();
   8:         ...
   9:     ret[1] = getComponents ().length;
  10:     Iterator i = layers.entrySet().iterator ();
  11:     while (i.hasNext())

View Full Code Here
   1: import java.util.SortedMap;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: 
   6:         elements = new TreeMap(map);
   7:     }
   8:         ...
   9:     public Set entrySet() {
  10:         return elements.entrySet();
  11:     }
  12:         ...
  13:     
  14:     private TreeMap elements = new TreeMap();

View Full Code Here

firstKey

public K firstKey()
Returns the first (lowest) key currently in this sorted map.
Specified by:
firstKey in interface SortedMap<K,V>
Returns:
the first (lowest) key currently in this sorted map.
Throws:
NoSuchElementException - Map is empty.
Usages and Demos :

View More Examples of firstKey()
   1: 
   2: import java.util.TreeMap;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:   protected TreeMap explanations;
   7:   protected Object  appData;
   8:         ...
   9:     this.element = element;
  10:     explanations = new TreeMap();
  11:     Iterator it = element.getChildren( "explanation", element.getNamespace() ).iterator();
  12:         ...
  13:     {
  14:       return (String)explanations.firstKey();

View Full Code Here
   1:     public synchronized void sweep() {
   2:         TreeMap costTreeMap = new TreeMap(new CostComparator());
   3:         for (Iterator i = cacheHashMap.entrySet().iterator(); i.hasNext();) {
   4:         ...
   5:         for (int i = cacheHashMap.size(); i > TRESHOLD; i--) {
   6:             Object kk = costTreeMap.firstKey();
   7:             Object k = costTreeMap.get(kk);
   8:             cacheHashMap.remove(k);
   9:             costTreeMap.remove(kk);

View Full Code Here
   1: import java.util.Locale;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   protected TreeMap            displayNames;
   7:   protected Result             referenced;
   8:         ...
   9:     super( element, appContext );
  10:     displayNames = new TreeMap();
  11:     if( ! isElement( element, appContext ) )
  12:         ...
  13:     {
  14:       return (String)displayNames.firstKey();

View Full Code Here
   1: import java.util.Map;
   2: import java.util.TreeMap;
   3: import java.util.Vector;
   4:         ...
   5:     private Map indexes = null;
   6:     TreeMap startsPos = null;
   7:     private int windows = 0;
   8:         ...
   9:         this.indexes = new HashMap();
  10:         startsPos = new TreeMap();
  11:     }
  12:         ...
  13:         
  14:         startsPos.remove(startsPos.firstKey());

View Full Code Here
   1: import java.util.Locale;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:   private Limits.TimeLimits totalSessions;
   6:   private TreeMap           otherRestrictions;
   7:   private List              seeAlsos;
   8:         ...
   9:     totalSessions     = new Limits.TimeLimits();
  10:     otherRestrictions = new TreeMap();
  11: 
  12:         ...
  13:     {
  14:       return (String)otherRestrictions.firstKey();

View Full Code Here

get

public V get(Object key)
Returns the value to which this map maps the specified key. Returns null if the map contains no mapping for this key. A return value of null does not necessarily indicate that the map contains no mapping for the key; it's also possible that the map explicitly maps the key to null. The containsKey operation may be used to distinguish these two cases.
Specified by:
get in interface Map<K,V>
Overrides:
get in interface AbstractMap<K,V>
Parameters:
key - key whose associated value is to be returned.
Returns:
the value to which this map maps the specified key, or null if the map contains no mapping for the key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and this map uses natural ordering, or its comparator does not tolerate null keys.
Usages and Demos :

View More Examples of get(Object key)
   1:    private String[] rows = null;
   2:    private TreeMap cityMap = null;
   3: 
   4:         ...
   5:               PickOneFieldException pexp = (PickOneFieldException)exp;
   6:               cityMap = (TreeMap)pexp.getAlternateValues();
   7:                 Set keys = cityMap.keySet();
   8:         ...
   9:         {
  10:             return cityMap.get(currentRow);
  11:         }

View Full Code Here
   1:     public synchronized Object getCache(String identifier) {
   2:         CachedObject cachedObject = (CachedObject) cacheHashMap.get(identifier);
   3:         Object obj = null;
   4:         ...
   5:     public synchronized void sweep() {
   6:         TreeMap costTreeMap = new TreeMap(new CostComparator());
   7:         for (Iterator i = cacheHashMap.entrySet().iterator(); i.hasNext();) {
   8:         ...
   9:             Object kk = costTreeMap.firstKey();
  10:             Object k = costTreeMap.get(kk);
  11:             cacheHashMap.remove(k);

View Full Code Here
   1: 
   2:     protected TreeMap map;
   3: 
   4:         ...
   5:     public SelectorListModel(Object[] values) {
   6:       map = new TreeMap();
   7:       if (values != null) {
   8:         ...
   9:       Set keys = map.keySet();
  10:       return map.get(keys.toArray()[index]);
  11:     }

View Full Code Here
   1: import java.awt.Color;
   2: import java.util.TreeMap;
   3: import javax.swing.table.AbstractTableModel;
   4:         ...
   5: {
   6:   private TreeMap colors;
   7:   private String[] colorNames;
   8:         ...
   9:       case 5:
  10:         return colors.get(computeColorName(row));
  11:       default:

View Full Code Here
   1: 
   2: import java.util.TreeMap;
   3: import java.util.NoSuchElementException;
   4:         ...
   5: public class Timeout extends Thread {
   6:    private TreeMap map = null;
   7: 
   8:         ...
   9:       this.useWeakReference = useWeakReference;
  10:       this.map = new TreeMap();
  11:       setDaemon(true);
  12:         ...
  13:             key = new Timestamp(endNanos);
  14:             Object obj = map.get(key);

View Full Code Here

headMap

public SortedMap headMap(K toKey)
Returns a view of the portion of this map whose keys are strictly less than toKey. The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa. The returned sorted map supports all optional map operations.

The sorted map returned by this method will throw an IllegalArgumentException if the user attempts to insert a key greater than or equal to toKey.

Note: this method always returns a view that does not contain its (high) endpoint. If you need a view that does contain this endpoint, and the key type allows for calculation of the successor a given key, merely request a headMap bounded by successor(highEndpoint). For example, suppose that suppose that m is a sorted map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in m whose keys are less than or equal to high:

     SortedMap head = m.headMap(high+"\0");
 
Specified by:
headMap in interface SortedMap<K,V>
Parameters:
toKey - high endpoint (exclusive) of the headMap.
Returns:
a view of the portion of this map whose keys are strictly less than toKey.
Throws:
ClassCastException - if toKey is not compatible with this map's comparator (or, if the map has no comparator, if toKey does not implement Comparable).
IllegalArgumentException - if this map is itself a subMap, headMap, or tailMap, and toKey is not within the specified range of the subMap, headMap, or tailMap.
NullPointerException - if toKey is null and this map uses natural order, or its comparator does not tolerate null keys.
Usages and Demos :

View More Examples of headMap(K toKey)
   1: import java.util.SortedMap;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: 
   6:         elements = new TreeMap(map);
   7:     }
   8:         ...
   9:         
  10:         return elements.headMap((Priority) toKey);
  11:     }
  12:         ...
  13:     
  14:     private TreeMap elements = new TreeMap();

View Full Code Here

keySet

public Set keySet()
Returns a Set view of the keys contained in this map. The set's iterator will return the keys in ascending order. The map is backed by this TreeMap instance, so changes to this map are reflected in the Set, and vice-versa. The Set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
Specified by:
keySet in interface Map<K,V>
Overrides:
keySet in interface AbstractMap<K,V>
Returns:
a set view of the keys contained in this TreeMap.
Usages and Demos :

View More Examples of keySet()
   1: 
   2:    private TreeMap departments = new TreeMap();
   3: 
   4:         ...
   5:    
   6:    public TreeMap getDepartments() {
   7:       return departments;
   8:         ...
   9:    public Collection getDepartmentNames() {
  10:       return departments.keySet();
  11:    }

View Full Code Here
   1: import java.util.Comparator;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:     private void init() {
   6:         fCatMap = new TreeMap(new Comparator() {
   7:             public int compare(Object arg0, Object arg1) {
   8:         ...
   9:         });
  10:         fConMap = new TreeMap();
  11:         Command[] commands = fComServ.getDefinedCommands();
  12:         ...
  13:         case F_CAT_CONTENT:
  14:             return fCatMap.keySet().toArray();

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:   protected String id;
   6:   private TreeMap registeredHandlers = new TreeMap();
   7: 
   8:         ...
   9:   {
  10:     return registeredHandlers.keySet().iterator();
  11:   }

View Full Code Here
   1: {
   2:    private final TreeMap entries;
   3: 
   4:         ...
   5:       this.owner = owner;
   6:       entries = new TreeMap();
   7:       entries.put(owner, new Integer(0));
   8:         ...
   9:    {
  10:       return entries.keySet();
  11:    }
  12:         ...
  13:       Address member = null;
  14:       Set keyEntries = entries.keySet();

View Full Code Here
   1: {
   2:    private TreeMap entries;
   3: 
   4:         ...
   5:       this.owner = owner;
   6:       entries = new TreeMap();
   7:       entries.put(owner, new Integer(0));
   8:         ...
   9:    {
  10:       return entries.keySet();
  11:    }
  12:         ...
  13:       int thisVectorValue = 0;
  14:       Set keyEntries = entries.keySet();

View Full Code Here

lastKey

public K lastKey()
Returns the last (highest) key currently in this sorted map.
Specified by:
lastKey in interface SortedMap<K,V>
Returns:
the last (highest) key currently in this sorted map.
Throws:
NoSuchElementException - Map is empty.
Usages and Demos :

View More Examples of lastKey()
   1: import jp.ujihara.java.util.Map;
   2: import jp.ujihara.java.util.TreeMap;
   3: 
   4:         ...
   5:   {
   6:     layers = new TreeMap ();
   7:     componentToLayer = new Hashtable ();
   8:         ...
   9:         return 0;
  10:     return ((Integer)(layers.lastKey())).intValue ();
  11:   }

View Full Code Here
   1: import java.util.SortedMap;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: 
   6:         elements = new TreeMap(map);
   7:     }
   8:         ...
   9:     public Object lastKey() {
  10:         return elements.lastKey();
  11:     }
  12:         ...
  13:     
  14:     private TreeMap elements = new TreeMap();

View Full Code Here
   1: 
   2:     private final TreeMap delivered_msgs=new TreeMap();
   3: 
   4:         ...
   5:                 if(m.size() > 0)
   6:                     lowest_seen=Math.max(lowest_seen, ((Long)m.lastKey()).longValue());
   7:             }
   8:         ...
   9:             try {min=(Long)delivered_msgs.firstKey();} catch(NoSuchElementException ex) {}
  10:             try {max=(Long)delivered_msgs.lastKey();}  catch(NoSuchElementException ex) {}
  11:         }
  12:         ...
  13:             try {first=(Long)received_msgs.firstKey();} catch(NoSuchElementException ex) {}
  14:             try {last=(Long)received_msgs.lastKey();}   catch(NoSuchElementException ex) {}

View Full Code Here

put

public V put(K key,
             V value)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for this key, the old value is replaced.
Specified by:
put in interface Map<K,V>
Overrides:
put in interface AbstractMap<K,V>
Parameters:
key - key with which the specified value is to be associated.
value - value to be associated with the specified key.
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and this map uses natural order, or its comparator does not tolerate null keys.
Usages and Demos :

View More Examples of put(K key,V value)
   1:   public static void main (String args[]) {
   2:     TreeMap map = new TreeMap();
   3:         ...
   4:     map.put("Virginia", "Richmond");
   5:         ...
   6:     map.put("Massachusetts", "Boston");
   7:     map.put("New York", "Albany");
   8:         ...
   9:     map.put("Maryland", "Annapolis");

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.TreeMap;
   3: import java.util.Vector;
   4:         ...
   5: 
   6:           listElement.put("CustomFieldID", addId);
   7:         ...
   8:           listElement.put("Field", field);
   9:         ...
  10:           listElement.put("Value", value);

View Full Code Here
   1: import java.io.FileOutputStream;
   2: import java.util.TreeMap;
   3: import java.util.ArrayList;
   4:         ...
   5:                         int localeIndex) throws IOException {
   6:         TreeMap treeMap = new TreeMap();
   7:         File licenseFile;
   8:         ...
   9:                 treeMap.clear();
  10:                 treeMap.put("AgreementText", realLicenseInfo);
  11:                 WinMsiUtility.winMsiSetProperty(
  12:         ...
  13:                 treeMap.clear();
  14:                 treeMap.put("AfterWelcomeDlg", "LicenseAgreementDlg");

View Full Code Here

putAll

public void putAll(extends K,
                   V> map)
Copies all of the mappings from the specified map to this map. These mappings replace any mappings that this map had for any of the keys currently in the specified map.
Specified by:
putAll in interface Map<K,V>
Overrides:
putAll in interface AbstractMap<K,V>
Parameters:
map - mappings to be stored in this map.
Throws:
ClassCastException - class of a key or value in the specified map prevents it from being stored in this map.
NullPointerException - if the given map is null or this map does not permit null keys and a key in the specified map is null.

remove

public V remove(Object key)
Removes the mapping for this key from this TreeMap if present.
Specified by:
remove in interface Map<K,V>
Overrides:
remove in interface AbstractMap<K,V>
Parameters:
key - key for which mapping should be removed
Returns:
previous value associated with specified key, or null if there was no mapping for key. A null return can also indicate that the map previously associated null with the specified key.
Throws:
ClassCastException - key cannot be compared with the keys currently in the map.
NullPointerException - key is null and this map uses natural order, or its comparator does not tolerate null keys.
Usages and Demos :

View More Examples of remove(Object key)
   1:     Vector passagesByQueries = (Vector)input;
   2:     TreeMap passages = new TreeMap();
   3: 
   4:         ...
   5:           {
   6:             passages.remove("" + passageAnt.getId());
   7:             passages.put("" + passage.getId(),passage);
   8:         ...
   9: 
  10:   private Document[] treeMapToArray(TreeMap map)
  11:   {
  12:         ...
  13:       passages[i] = passage;
  14:       map.remove(key);

View Full Code Here
   1: import java.util.List;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: 
   6:   final TreeMap atts_ = new TreeMap();
   7:   final TObjectIntHashMap attUsed_ = new TObjectIntHashMap();
   8:         ...
   9:     if (newUsed <= 0) {
  10:       attUsed_.remove(att);
  11:         ...
  12:       atts_.remove(att);

View Full Code Here
   1: import java.util.Set;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:     
   6:     TreeMap startsPos = null;
   7:     private int size = 0;
   8:         ...
   9:         comparator = schema.getComparator(0);
  10:         startsPos = new TreeMap();
  11:     }
  12:         ...
  13:                 if (remove){
  14:                     ind.remove(crtInteger);

View Full Code Here
   1: import java.util.StringTokenizer;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:     
   6:     private TreeMap fFriends = new TreeMap();
   7:      
   8:         ...
   9:     public void removeFriend(PackageFriend friend) {
  10:         fFriends.remove(friend.getName());
  11:         setDirective(FRIENDS, null);
  12:         ...
  13:         if (table.containsKey(Constants.USES_DIRECTIVE))
  14:             usesValue = table.remove(Constants.USES_DIRECTIVE);

View Full Code Here
   1:       });
   2:       TreeMap map = ((CtrlFileCustomGUIModule) module).getCtrlFiles();
   3:       String fileName = null;
   4:         ...
   5:         {
   6:           TreeMap map = ((CtrlFileCustomGUIModule) module).getCtrlFiles();
   7:         ...
   8:           map.remove("default");
   9:           map.put("default", new CtrlFile("default"));

View Full Code Here

size

public int size()
Returns the number of key-value mappings in this map.
Specified by:
size in interface Map<K,V>
Overrides:
size in interface AbstractMap<K,V>
Returns:
the number of key-value mappings in this map.
Usages and Demos :

View More Examples of size()
   1: import java.util.NoSuchElementException;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: 
   6:     TreeMap contents = new TreeMap();
   7:     
   8:         ...
   9:     public int size() {
  10:         return contents.size();
  11:     }

View Full Code Here
   1: import java.util.Set;
   2: import java.util.TreeMap;
   3: import java.util.NoSuchElementException;
   4:         ...
   5: {
   6:   TreeMap roots = new TreeMap();
   7:   HashMap entries = new HashMap();
   8:         ...
   9:   public int size(){
  10:     return roots.size();
  11:   }

View Full Code Here
   1: import java.util.SortedMap;
   2: import java.util.TreeMap;
   3: import java.util.Vector;
   4:         ...
   5:     protected Profile m_profile;
   6:     protected TreeMap m_services;
   7:     
   8:         ...
   9:         m_profile=((ServiceModelerViewable)m_module.getAppDriver().getSelectedViewable()).getServiceModel();
  10:         m_services=new TreeMap();
  11:         refresh();
  12:         ...
  13:     public int getSize() {
  14:         return m_services.size();

View Full Code Here
   1: import java.util.Set;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: {
   6:   protected final TreeMap map;
   7: 
   8:         ...
   9:   {
  10:     map = new TreeMap(NameComponentComparator.singleton);
  11:   }
  12:         ...
  13:   {
  14:     return map.size();

View Full Code Here
   1: 
   2:     protected TreeMap map;
   3: 
   4:         ...
   5:     public SelectorListModel(Object[] values) {
   6:       map = new TreeMap();
   7:       if (values != null) {
   8:         ...
   9:     public int getSize() {
  10:       return map.size();
  11:     }

View Full Code Here

subMap

public SortedMap subMap(K fromKey,
                             K toKey)
Returns a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive. (If fromKey and toKey are equal, the returned sorted map is empty.) The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa. The returned sorted map supports all optional map operations.

The sorted map returned by this method will throw an IllegalArgumentException if the user attempts to insert a key less than fromKey or greater than or equal to toKey.

Note: this method always returns a half-open range (which includes its low endpoint but not its high endpoint). If you need a closed range (which includes both endpoints), and the key type allows for calculation of the successor a given key, merely request the subrange from lowEndpoint to successor(highEndpoint). For example, suppose that m is a sorted map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in m whose keys are between low and high, inclusive:

    SortedMap sub = m.submap(low, high+"\0");
A similar technique can be used to generate an open range (which contains neither endpoint). The following idiom obtains a view containing all of the key-value mappings in m whose keys are between low and high, exclusive:
    SortedMap sub = m.subMap(low+"\0", high);
Specified by:
subMap in interface SortedMap<K,V>
Parameters:
fromKey - low endpoint (inclusive) of the subMap.
toKey - high endpoint (exclusive) of the subMap.
Returns:
a view of the portion of this map whose keys range from fromKey, inclusive, to toKey, exclusive.
Throws:
ClassCastException - if fromKey and toKey cannot be compared to one another using this map's comparator (or, if the map has no comparator, using natural ordering).
IllegalArgumentException - if fromKey is greater than toKey.
NullPointerException - if fromKey or toKey is null and this map uses natural order, or its comparator does not tolerate null keys.
Usages and Demos :

View More Examples of subMap(K fromKey,K toKey)
   1: import java.util.SortedMap;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: 
   6:         elements = new TreeMap(map);
   7:     }
   8:         ...
   9:     public SortedMap subMap(Object fromKey, Object toKey) {
  10:         return elements.subMap(fromKey, toKey);
  11:     }
  12:         ...
  13:     
  14:     private TreeMap elements = new TreeMap();

View Full Code Here

super K> comparator

public Comparatorsuper K> comparator()
Returns the comparator used to order this map, or null if this map uses its keys' natural order.
Specified by:
super K> comparator in interface SortedMap<K,V>
Returns:
the comparator associated with this sorted map, or null if it uses its keys' natural sort method.

tailMap

public SortedMap tailMap(K fromKey)
Returns a view of the portion of this map whose keys are greater than or equal to fromKey. The returned sorted map is backed by this map, so changes in the returned sorted map are reflected in this map, and vice-versa. The returned sorted map supports all optional map operations.

The sorted map returned by this method will throw an IllegalArgumentException if the user attempts to insert a key less than fromKey.

Note: this method always returns a view that contains its (low) endpoint. If you need a view that does not contain this endpoint, and the element type allows for calculation of the successor a given value, merely request a tailMap bounded by successor(lowEndpoint). For example, suppose that m is a sorted map whose keys are strings. The following idiom obtains a view containing all of the key-value mappings in m whose keys are strictly greater than low:

     SortedMap tail = m.tailMap(low+"\0");
 
Specified by:
tailMap in interface SortedMap<K,V>
Parameters:
fromKey - low endpoint (inclusive) of the tailMap.
Returns:
a view of the portion of this map whose keys are greater than or equal to fromKey.
Throws:
ClassCastException - if fromKey is not compatible with this map's comparator (or, if the map has no comparator, if fromKey does not implement Comparable).
IllegalArgumentException - if this map is itself a subMap, headMap, or tailMap, and fromKey is not within the specified range of the subMap, headMap, or tailMap.
NullPointerException - if fromKey is null and this map uses natural order, or its comparator does not tolerate null keys.
Usages and Demos :

View More Examples of tailMap(K fromKey)
   1: import java.util.Random;
   2: import java.util.TreeMap;
   3: import seda.sandStorm.api.ConfigDataIF;
   4:         ...
   5: 
   6:     protected static TreeMap instances = new TreeMap ();
   7: 
   8:         ...
   9:                 expected_succ = (BigInteger) 
  10:                     instances.tailMap(key).firstKey ();
  11:                 assert (expected_succ == null)

View Full Code Here
   1: import java.util.SortedMap;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5: 
   6:         elements = new TreeMap(map);
   7:     }
   8:         ...
   9:     public SortedMap tailMap(Object fromKey) {
  10:         return elements.tailMap(fromKey);
  11:     }
  12:         ...
  13:     
  14:     private TreeMap elements = new TreeMap();

View Full Code Here

values

public Collection values()
Returns a collection view of the values contained in this map. The collection's iterator will return the values in the order that their corresponding keys appear in the tree. The collection is backed by this TreeMap instance, so changes to this map are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from the map through the Iterator.remove, Collection.remove, removeAll, retainAll, and clear operations. It does not support the add or addAll operations.
Specified by:
values in interface Map<K,V>
Overrides:
values in interface AbstractMap<K,V>
Returns:
a collection view of the values contained in this map.
Usages and Demos :

View More Examples of values()
   1: 
   2:    private TreeMap members = new TreeMap();
   3: 
   4:         ...
   5:    public Collection getMembers() {
   6:       return members.values(); 
   7:    }
   8:          
   9:    public void addMember(String name, String phone, String email) {

View Full Code Here
   1: 
   2:    private TreeMap departments = new TreeMap();
   3: 
   4:         ...
   5:    
   6:    public TreeMap getDepartments() {
   7:       return departments;
   8:         ...
   9:    public Collection getDepartmentValues() {
  10:       return departments.values(); 
  11:    }

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.TreeMap;
   3: 
   4:         ...
   5:     public Iterator iterator () {
   6:         return results.values().iterator();
   7:     }
   8: 
   9:     protected void _execute () throws SigPathDatabaseException {

View Full Code Here
   1: {
   2:    private static TreeMap map = new TreeMap();
   3: 
   4:         ...
   5:    {
   6:        return map.values().iterator();
   7:    }
   8: 
   9:    public boolean equals(

View Full Code Here
   1: {
   2:    private static TreeMap map = new TreeMap();
   3: 
   4:         ...
   5:    {
   6:        return map.values().iterator();
   7:    }
   8: 

View Full Code Here