java.util

Class HashMap<K,V>

Implemented Interfaces:
Cloneable, Map<K,V>, Serializable
Known Direct Subclasses:
ContextBase, CustomProperties, FastHashMap, HashMapContext, HtmlTagMap, JUnit4TestAdapterCache, LinkedHashMap<K,V>, MultiHashMap, PrinterStateReasons, PropertyIDMap, SectionIDMap, TagMap, WebColors

public class HashMap<K,V>
extends AbstractMap<K,V>
implements Map<K,V>, Cloneable, Serializable

Hash table based implementation of the Map interface. This implementation provides all of the optional map operations, and permits null values and the null key. (The HashMap class is roughly equivalent to Hashtable, except that it is unsynchronized and permits nulls.) This class makes no guarantees as to the order of the map; in particular, it does not guarantee that the order will remain constant over time.

This implementation provides constant-time performance for the basic operations (get and put), assuming the hash function disperses the elements properly among the buckets. Iteration over collection views requires time proportional to the "capacity" of the HashMap instance (the number of buckets) plus its size (the number of key-value mappings). Thus, it's very important not to set the initial capacity too high (or the load factor too low) if iteration performance is important.

An instance of HashMap has two parameters that affect its performance: initial capacity and load factor. The capacity is the number of buckets in the hash table, and the initial capacity is simply the capacity at the time the hash table is created. The load factor is a measure of how full the hash table is allowed to get before its capacity is automatically increased. When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the capacity is roughly doubled by calling the rehash method.

As a general rule, the default load factor (.75) offers a good tradeoff between time and space costs. Higher values decrease the space overhead but increase the lookup cost (reflected in most of the operations of the HashMap class, including get and put). The expected number of entries in the map and its load factor should be taken into account when setting its initial capacity, so as to minimize the number of rehash operations. If the initial capacity is greater than the maximum number of entries divided by the load factor, no rehash operations will ever occur.

If many mappings are to be stored in a HashMap instance, creating it with a sufficiently large capacity will allow the mappings to be stored more efficiently than letting it perform automatic rehashing as needed to grow the table.

Note that this implementation is not synchronized. If multiple threads access this 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 a key that an instance already contains 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 HashMap(...));
 

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 will throw 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:
Object.hashCode(), Collection, Map, TreeMap, Hashtable, Serialized Form

Constructor Summary

HashMap()
Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).
HashMap(extends K, V> m)
Constructs a new HashMap with the same mappings as the specified Map.
HashMap(int initialCapacity)
Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75).
HashMap(int initialCapacity, float loadFactor)
Constructs an empty HashMap with the specified initial capacity and load factor.

Method Summary

void
clear()
Removes all mappings from this map.
Object
clone()
Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned.
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 collection view of the mappings contained in this map.
V
get(Object key)
Returns the value to which the specified key is mapped in this identity hash map, or null if the map contains no mapping for this key.
boolean
isEmpty()
Returns true if this map contains no key-value mappings.
Set
keySet()
Returns a set view of the keys contained in this map.
V
put(K key, V value)
Associates the specified value with the specified key in this map.
void
putAll(extends K, V> m)
Copies all of the mappings from the specified map to this map These mappings will replace any mappings that this map had for any of the keys currently in the specified map.
V
remove(Object key)
Removes the mapping for this key from this map if present.
int
size()
Returns the number of key-value mappings in this map.
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

HashMap

public HashMap()
Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).
Usages and Demos :

View More Examples of HashMap()
   1:         assertTrue(CollectionUtils.isEmpty((Map)null));
   2:         assertTrue(CollectionUtils.isEmpty(new HashMap()));
   3:         assertTrue(CollectionUtils.isEmpty(new HashSet()));
   4:         ...
   5: 
   6:         Map map = new HashMap();
   7:         map.put("foo", "bar");
   8: 
   9:         assertFalse(CollectionUtils.isEmpty(map));

View Full Code Here
   1:         List list = new ArrayList();
   2:         list.add(new ConvertedSourcePair(HashMap.class, new HashMap()));
   3:         list.add(new ConvertedSourcePair(null, null));
   4:         list.add(new ConvertedSourcePair(ObjectToClassConverterTestCase.class, this));
   5:         list.add(new ConvertedSourcePair(String.class, ""));

View Full Code Here
   1:         namedFunctionCallDeclaration.setFunctionCallInternDeclaration(
   2:             (IFunctionCallInternDeclaration)_prototypeFunctionCallInternDecl.copy(new HashMap()));
   3: 
   4:         if (Assert.ASSERTION_ON)
   5:             Assert.assertEquals(

View Full Code Here
   1:     public Map makeEmptyMap() {
   2:         return UnmodifiableOrderedMap.decorate(ListOrderedMap.decorate(new HashMap()));
   3:     }
   4:         ...
   5:     public Map makeFullMap() {
   6:         OrderedMap m = ListOrderedMap.decorate(new HashMap());
   7:         addSampleMappings(m);
   8:         return UnmodifiableOrderedMap.decorate(m);
   9:     }

View Full Code Here
   1:         list.add(new ConvertedSourcePair(Boolean.FALSE, new ArrayList()));            
   2:         list.add(new ConvertedSourcePair(Boolean.FALSE, new HashMap()));
   3:     }
   4:     
   5:     public void addNumberConversions(List list) {

View Full Code Here

HashMap

public HashMap(extends K,
               V> m)
Constructs a new HashMap with the same mappings as the specified Map. The HashMap is created with default load factor (0.75) and an initial capacity sufficient to hold the mappings in the specified Map.
Parameters:
m - the map whose mappings are to be placed in this map.
Throws:
NullPointerException - if the specified map is null.
Usages and Demos :

View More Examples of HashMap(extends K,V> m)
   1: public class LocalSolrQueryRequest extends SolrQueryRequestBase {
   2:   public final static Map emptyArgs = new HashMap(0,1);
   3: 
   4:   protected static SolrParams makeParams(String query, String qtype, int start, int limit, Map args) {
   5:     Map<String,String[]> map = new HashMap<String,String[]>();

View Full Code Here
   1:     SearchPath path;
   2:     public Map classMap = new HashMap(128, 0.75f);
   3: 
   4:     public ClassManager() {
   5:         path = null;

View Full Code Here
   1: 
   2:     private static java.util.HashMap defaultImplementations = new java.util.HashMap(16, 0.75F);
   3:     private static java.util.HashMap rootTagMap = new java.util.HashMap();
   4:     public final static net.sourceforge.czt.circus.jaxb.gen.impl.runtime.GrammarInfo grammarInfo = new net.sourceforge.czt.circus.jaxb.gen.impl.runtime.GrammarInfoImpl(rootTagMap, defaultImplementations, (org.w3._2001.xmlschema.ObjectFactory.class));
   5:     public final static java.lang.Class version = (org.w3._2001.xmlschema.impl.JAXBVersion.class);

View Full Code Here
   1: 
   2:     private static java.util.HashMap defaultImplementations = new java.util.HashMap(16, 0.75F);
   3:     private static java.util.HashMap rootTagMap = new java.util.HashMap();
   4:     public final static jp.ac.nao.jvop3.model.ADQL.v1_0_3.impl.runtime.GrammarInfo grammarInfo = new jp.ac.nao.jvop3.model.ADQL.v1_0_3.impl.runtime.GrammarInfoImpl(rootTagMap, defaultImplementations, (jp.ac.nao.jvop3.model.ADQL.v1_0_3.XMLSchema.ObjectFactory.class));
   5:     public final static java.lang.Class version = (jp.ac.nao.jvop3.model.ADQL.v1_0_3.XMLSchema.impl.JAXBVersion.class);

View Full Code Here
   1: public abstract class JVMUtilities {
   2:     private final static Map types  = new HashMap(11, 1.0f);
   3: 
   4:         ...
   5:     private final static Map stypes = new HashMap(11, 1.0f);
   6: 
   7:     static {
   8:     types.put(byte.class,    "B");

View Full Code Here

HashMap

public HashMap(int initialCapacity)
Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75).
Parameters:
initialCapacity - the initial capacity.
Throws:
IllegalArgumentException - if the initial capacity is negative.
Usages and Demos :

View More Examples of HashMap(int initialCapacity)
   1: 
   2:         final Map baseSettings= new HashMap(((Profile)fSortedProfiles.get(fProfileCombo.getSelectionIndex())).getSettings());
   3:         final String profileName= fNameText.getText();
   4:         
   5:         fCreatedProfile= new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());

View Full Code Here
   1:         {
   2:             securityConstraintsDefsMap = new HashMap((getSecurityConstraintsDefs().size() * 2) + 1);
   3:             Iterator definitionsIter = getSecurityConstraintsDefs().iterator();
   4:             while (definitionsIter.hasNext())
   5:             {

View Full Code Here
   1:         String[] groupNames = TurbineIntake.getGroupNames();
   2:         groups = new HashMap((int)(1.25*groupNames.length + 1));
   3:         ...
   4:         pullMap = new HashMap((int)(1.25*groupNames.length + 1));
   5: 
   6:         for (int i=groupNames.length-1; i>=0; i--)
   7:         {

View Full Code Here
   1:         }
   2:         groups = new HashMap((int) (1.25 * groupCount + 1));
   3:         ...
   4:         pullMap = new HashMap((int) (1.25 * groupCount + 1));
   5: 
   6:         for (int i = groupCount - 1; i >= 0; i--)
   7:         {

View Full Code Here
   1:     public IPluginModelBase[] createTargetModels(BundleDescription[] bundleDescriptions) {
   2:         HashMap models = new HashMap((4/3) * bundleDescriptions.length + 1); 
   3:         for (int i = 0; i < bundleDescriptions.length; i++) {
   4:             BundleDescription desc = bundleDescriptions[i];
   5:             IPluginModelBase base = createExternalModel(desc);

View Full Code Here

HashMap

public HashMap(int initialCapacity,
               float loadFactor)
Constructs an empty HashMap with the specified initial capacity and load factor.
Parameters:
initialCapacity - The initial capacity.
loadFactor - The load factor.
Throws:
IllegalArgumentException - if the initial capacity is negative or the load factor is nonpositive.
Usages and Demos :

View More Examples of HashMap(int initialCapacity,float loadFactor)
   1: public class LocalSolrQueryRequest extends SolrQueryRequestBase {
   2:   public final static Map emptyArgs = new HashMap(0,1);
   3: 
   4:   protected static SolrParams makeParams(String query, String qtype, int start, int limit, Map args) {
   5:     Map<String,String[]> map = new HashMap<String,String[]>();

View Full Code Here
   1:     SearchPath path;
   2:     public Map classMap = new HashMap(128, 0.75f);
   3: 
   4:     public ClassManager() {
   5:         path = null;

View Full Code Here
   1: 
   2:     private static java.util.HashMap defaultImplementations = new java.util.HashMap(16, 0.75F);
   3:     private static java.util.HashMap rootTagMap = new java.util.HashMap();
   4:     public final static net.sourceforge.czt.circus.jaxb.gen.impl.runtime.GrammarInfo grammarInfo = new net.sourceforge.czt.circus.jaxb.gen.impl.runtime.GrammarInfoImpl(rootTagMap, defaultImplementations, (org.w3._2001.xmlschema.ObjectFactory.class));
   5:     public final static java.lang.Class version = (org.w3._2001.xmlschema.impl.JAXBVersion.class);

View Full Code Here
   1: 
   2:     private static java.util.HashMap defaultImplementations = new java.util.HashMap(16, 0.75F);
   3:     private static java.util.HashMap rootTagMap = new java.util.HashMap();
   4:     public final static jp.ac.nao.jvop3.model.ADQL.v1_0_3.impl.runtime.GrammarInfo grammarInfo = new jp.ac.nao.jvop3.model.ADQL.v1_0_3.impl.runtime.GrammarInfoImpl(rootTagMap, defaultImplementations, (jp.ac.nao.jvop3.model.ADQL.v1_0_3.XMLSchema.ObjectFactory.class));
   5:     public final static java.lang.Class version = (jp.ac.nao.jvop3.model.ADQL.v1_0_3.XMLSchema.impl.JAXBVersion.class);

View Full Code Here
   1: public abstract class JVMUtilities {
   2:     private final static Map types  = new HashMap(11, 1.0f);
   3: 
   4:         ...
   5:     private final static Map stypes = new HashMap(11, 1.0f);
   6: 
   7:     static {
   8:     types.put(byte.class,    "B");

View Full Code Here

Method Details

clear

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

View More Examples of clear()
   1: public class LinesBase  {
   2:     HashMap lines ;
   3:     
   4:         ...
   5:     public  LinesBase(){
   6:         lines = new HashMap() ;            
   7:     } 
   8:         ...
   9:     public void reset(){
  10:         lines.clear();
  11:     } 

View Full Code Here
   1: public class ArrowsBase  {
   2:     HashMap arrows ;
   3:     
   4:         ...
   5:     public  ArrowsBase(){
   6:         arrows = new HashMap() ;            
   7:     } 
   8:         ...
   9:     public void reset(){
  10:         arrows.clear();
  11:     } 

View Full Code Here
   1: public class AgentsBase  {
   2:     HashMap agents;
   3:     
   4:         ...
   5:     public  AgentsBase(){
   6:         agents = new HashMap() ;            
   7:     } 
   8:         ...
   9:     public void reset(){
  10:         agents.clear();
  11:     } 

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: 
   4:         ...
   5: 
   6:     private static HashMap registry = new HashMap(100);
   7: 
   8:         ...
   9:     public static void clear() {
  10:     registry.clear();
  11:     }

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: import java.util.LinkedList;
   4:         ...
   5:     private LinkedList m_list = new LinkedList();
   6:     private HashMap    m_map  = new HashMap();
   7:     
   8:         ...
   9:     public void clear() {
  10:         m_list.clear();
  11:         ...
  12:         m_map.clear();

View Full Code Here

clone

public Object clone()
Returns a shallow copy of this HashMap 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.ArrayList;
   2: import java.util.HashMap;
   3: 
   4:         ...
   5: 
   6:   private HashMap map;
   7:   private ArrayList names;
   8:         ...
   9:   {
  10:     map = new HashMap();
  11:     names = new ArrayList();
  12:         ...
  13:     {
  14:       map = (HashMap) map.clone();

View Full Code Here
   1: import javax.jms.TopicConnectionFactory;
   2: import java.util.HashMap;
   3: 
   4:         ...
   5: 
   6:     public QueueConnectionFactory getQueueConnectionFactory(HashMap properties)
   7:             throws Exception {
   8:         ...
   9:         properties = (HashMap) properties.clone();
  10:         properties.put(CONNECTION_FACTORY_CLASS, QCF_CLASS);
  11:         ...
  12: 
  13:     public TopicConnectionFactory getTopicConnectionFactory(HashMap properties)

View Full Code Here
   1: import javax.jms.TopicConnectionFactory;
   2: import java.util.HashMap;
   3: 
   4:         ...
   5: 
   6:     public QueueConnectionFactory getQueueConnectionFactory(HashMap properties)
   7:             throws Exception {
   8:         ...
   9:         properties = (HashMap) properties.clone();
  10:         properties.put(CONNECTION_FACTORY_CLASS, QCF_CLASS);
  11:         ...
  12: 
  13:     public TopicConnectionFactory getTopicConnectionFactory(HashMap properties)

View Full Code Here
   1: import javax.jms.TopicConnectionFactory;
   2: import java.util.HashMap;
   3: 
   4:         ...
   5: 
   6:     public QueueConnectionFactory getQueueConnectionFactory(HashMap properties)
   7:             throws Exception {
   8:         ...
   9:         properties = (HashMap) properties.clone();
  10:         properties.put(CONNECTION_FACTORY_CLASS, QCF_CLASS);
  11:         ...
  12: 
  13:     public TopicConnectionFactory getTopicConnectionFactory(HashMap properties)

View Full Code Here
   1: import java.net.InetAddress;
   2: import java.util.HashMap;
   3: import java.util.Map;
   4:         ...
   5:       time = System.currentTimeMillis();
   6:       Iterator iter = ((HashMap)receivedPackets.clone()).keySet().iterator();
   7:       PacketDataWrapper dw;
   8:       while (iter.hasNext()) {
   9:         String tmpkey = (String)iter.next(); 

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 - The key whose presence in this map is to be tested
Returns:
true if this map contains a mapping for the specified key.
Usages and Demos :

View More Examples of containsKey(Object key)
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.containsKey(key);

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.containsKey(key);

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: 
   4:         ...
   5: 
   6:   private HashMap map;
   7: 
   8:         ...
   9: 
  10:   public MapAdapter(HashMap map) {
  11:     this.map = map;
  12:         ...
  13:   public boolean containsKey(Object key) {
  14:     return map != null && map.containsKey(key);

View Full Code Here
   1: import java.util.Iterator;
   2: import java.util.HashMap;
   3: import java.util.Collection;
   4:         ...
   5:     private Compartment outSide;
   6:     private HashMap inContactWith;
   7: 
   8:         ...
   9:         name = "compartment";
  10:         inContactWith = new HashMap();
  11:     }
  12:         ...
  13:     public boolean isInContactWith(Compartment c) {
  14:         return inContactWith.containsKey(c.getName());

View Full Code Here
   1: import java.io.IOException;
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: {
   6:   private HashMap props;
   7: 
   8:         ...
   9:   {
  10:     props = new HashMap();
  11:   }
  12:         ...
  13:       return false;
  14:     return props.containsKey(canonicalize(key));

View Full Code Here

containsValue

public boolean containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
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 this map maps one or more keys to the specified value.
Usages and Demos :

View More Examples of containsValue(Object value)
   1: public class LinesBase  {
   2:     HashMap lines ;
   3:     
   4:         ...
   5:     public  LinesBase(){
   6:         lines = new HashMap() ;            
   7:     } 
   8:         ...
   9:     public boolean contains(Line a ){
  10:         return lines.containsValue(a);
  11:     }

View Full Code Here
   1: public class ArrowsBase  {
   2:     HashMap arrows ;
   3:     
   4:         ...
   5:     public  ArrowsBase(){
   6:         arrows = new HashMap() ;            
   7:     } 
   8:         ...
   9:     public boolean contains(Arrow a ){
  10:         return arrows.containsValue(a);
  11:     }

View Full Code Here
   1: public class AgentsBase  {
   2:     HashMap agents;
   3:     
   4:         ...
   5:     public  AgentsBase(){
   6:         agents = new HashMap() ;            
   7:     } 
   8:         ...
   9:     public boolean containsAgent(Agent a ){
  10:         return agents.containsValue(a);
  11:     }

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.containsValue(value);

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.containsValue(value);

View Full Code Here

entrySet

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

View More Examples of entrySet()
   1: import java.util.Map;
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: {
   6:     private HashMap flies = new HashMap(10);
   7: 
   8:         ...
   9: 
  10:         for ( Iterator it = flies.entrySet().iterator() ; it.hasNext() ;  )
  11:         {

View Full Code Here
   1: import java.util.Map;
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: {
   6:     private HashMap flies = new HashMap();
   7:     private Flyweight lnkFlyweight;
   8:         ...
   9:         System.out.println("\n==========checkFlyweight()=============");
  10:         for ( Iterator it = flies.entrySet().iterator() ; it.hasNext() ;  )
  11:         {

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.entrySet();

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.entrySet();

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.entrySet();

View Full Code Here

get

public V get(Object key)
Returns the value to which the specified key is mapped in this identity hash map, or 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 is also possible that the map explicitly maps the key to null. The containsKey method 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 - the 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 this key.
See Also:
put(Object, Object)
Usages and Demos :

View More Examples of get(Object key)
   1: 
   2: import java.util.HashMap;
   3: 
   4:         ...
   5: 
   6:     HashMap hints = null;
   7:         ...
   8:     protected  HashMap getHints() {
   9:         return hints;
  10:         ...
  11:     public Object getHint( String hint ) {
  12:         return hints != null ? hints.get( hint ) : null; 

View Full Code Here
   1: public class ExportCACertCommand extends JSTKCommandAdapter {
   2:     private static HashMap defaults = new HashMap();
   3:     static {
   4:         ...
   5:             "  -cadir <cadir>      : CA directory.[" +
   6:             defaults.get("cadir") + "]\n" +
   7:             "  -cerfile <cerfile>  : File to write exported Certificate.[" +
   8:         ...
   9:             defaults.get("cerfile") + "]\n" +
  10:             "  -password <passwd>  : Password for CA keystore.\n";
  11:         ...
  12:             args.setDefaults(defaults);
  13:             String cerfile = args.get("cerfile");

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: 
   4:         ...
   5:     
   6:     private static HashMap fMap = new HashMap();
   7:     
   8:         ...
   9:             initialize();
  10:         return fMap.containsKey(oldId) ? fMap.get(oldId).toString() : null;
  11:     }

View Full Code Here
   1: public class GenSRCommand extends JSTKCommandAdapter{
   2:     private static HashMap defaults = new HashMap();
   3:     static {
   4:         ...
   5:             "  -algorithm <alg>    : Algorithm for secure random generator.[" +
   6:             defaults.get("algorithm") + "]\n" +
   7:             "  -size <size>        : no. of random bytes to be generated.[" +
   8:         ...
   9:             defaults.get("size") + "]\n" +
  10:             "  -seed <seed>        : seed to the random no. generator ( a long ).[" +
  11:         ...
  12:             defaults.get("seed") + "]\n" +

View Full Code Here
   1: public class GenKPCommand extends JSTKCommandAdapter{
   2:     private static HashMap defaults = new HashMap();
   3:     static {
   4:         ...
   5:             "  -algorithm <alg>    : Algorithm for secret key generator.[" +
   6:             defaults.get("algorithm") + "]\n" +
   7:             "  -keysize <keysize>  : Key size (in bits).[" +
   8:         ...
   9:             defaults.get("keysize") + "]\n" +
  10:             "  -action <action>    : what to do with the key?(print|save|discard).[" +
  11:         ...
  12:             defaults.get("action") + "]\n" +

View Full Code Here

isEmpty

public boolean isEmpty()
Returns true if this map contains no key-value mappings.
Specified by:
isEmpty in interface Map<K,V>
Overrides:
isEmpty in interface AbstractMap<K,V>
Returns:
true if this map contains no key-value mappings.
Usages and Demos :

View More Examples of isEmpty()
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.isEmpty();

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.isEmpty();

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.isEmpty();

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.isEmpty();

View Full Code Here
   1: {
   2:    HashMap hmap;
   3: 
   4:         ...
   5:    {
   6:       hmap = new HashMap();
   7:    }
   8:         ...
   9:    {
  10:       hmap = new HashMap(initialCapacity);
  11:    }
  12:         ...
  13:    {
  14:       return hmap.isEmpty();

View Full Code Here

keySet

public Set keySet()
Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from this 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 map.
Usages and Demos :

View More Examples of keySet()
   1: {
   2:     private HashMap books=new HashMap();
   3:     public BookService()
   4:         ...
   5:     {
   6:         return books.keySet().iterator();
   7:     }
   8:     public int getPrice(String id)
   9:     {

View Full Code Here
   1: package diva.util;
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:     HashMap _mapping;
   7: 
   8:         ...
   9:         if(_mapping == null) {
  10:            _mapping = new HashMap();
  11:         }
  12:         ...
  13:     public Iterator propertyNames(){
  14:         return _mapping.keySet().iterator();

View Full Code Here
   1: 
   2:     private HashMap m_map = new HashMap(300);
   3: 
   4:         ...
   5:     public void clear() {
   6:         m_map = new HashMap(300);
   7:     }
   8:         ...
   9:     public Iterator keys() {
  10:         return m_map.keySet().iterator();
  11:     }

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: public class EclHandlerConfig {
   6:     HashMap map = new HashMap();
   7:     public EclHandlerConfig(Element configElement) {
   8:         ...
   9:     public Iterator getHandlerNames() {
  10:         return map.keySet().iterator();
  11:     }

View Full Code Here
   1: import java.io.Serializable;
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:     private HashMap properties = new HashMap();
   7: 
   8:         ...
   9:     public Iterator listProperties() {
  10:         return properties.keySet().iterator();
  11:     }

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 HashMap previously associated null with the specified key.
Usages and Demos :

View More Examples of put(K key,V value)
   1: 
   2: import java.util.HashMap;
   3: import com.iplanet.jato.RequestContext;
   4:         ...
   5:     
   6:     public static HashMap displayItemMap, treeNodesMap;
   7:     
   8:         ...
   9:     displayItemMap.put(""+MODULE_EAR, "enterpriseApplicationsEdit");
  10:         ...
  11:     displayItemMap.put(""+MODULE_WAR, "webApplicationsEdit");

View Full Code Here
   1:   
   2:   static HashMap oStates;
   3: 
   4:         ...
   5:   static{
   6:     oStates = new HashMap();
   7:     
   8:         ...
   9:     oStates.put(""+IStates.iACTIVITY_CLOSED                      ,"jawflow.activity.closed");
  10:         ...
  11:     oStates.put(""+IStates.iACTIVITY_CLOSED_ABORTED              ,"jawflow.activity.closed.aborted");

View Full Code Here

putAll

public void putAll(extends K,
                   V> m)
Copies all of the mappings from the specified map to this map These mappings will 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:
m - mappings to be stored in this map.
Throws:
NullPointerException - if the specified map is null.
Usages and Demos :

View More Examples of putAll(extends K,V> m)
   1: 
   2: import java.util.HashMap;
   3: import java.util.Map;
   4:         ...
   5:     {
   6:         HashMap map = new HashMap();
   7: 
   8:         ...
   9:             {
  10:                 map.putAll(flattenBindings (c, b.getName()));
  11:             }

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: import java.util.Map;
   4:         ...
   5:     {
   6:         HashMap map = new HashMap();
   7: 
   8:         ...
   9:             {
  10:                 map.putAll(flattenBindings (c, b.getName()));
  11:             }

View Full Code Here

remove

public V remove(Object key)
Removes the mapping for this key from this map if present.
Specified by:
remove in interface Map<K,V>
Overrides:
remove in interface AbstractMap<K,V>
Parameters:
key - key whose mapping is to be removed from the map.
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.
Usages and Demos :

View More Examples of remove(Object key)
   1: 
   2: import java.util.HashMap;
   3: 
   4:         ...
   5: 
   6:     private HashMap idInUse = new HashMap();
   7: 
   8:         ...
   9:     public void releaseId(int id) {
  10:         idInUse.remove("" + id);
  11:     }

View Full Code Here
   1: import java.util.Collection;
   2: import java.util.HashMap;
   3: import java.util.Map;
   4:         ...
   5:         CompositeMap map = new CompositeMap();
   6:         map.addComposited(new HashMap());
   7:         map.setMutator(new CompositeMap.MapMutator() {
   8:         ...
   9:     private Map buildOne() {
  10:         HashMap map = new HashMap();
  11:         map.put("1", "one");
  12:         ...
  13:         
  14:         three.remove("5");

View Full Code Here
   1: import java.awt.*;
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5:     protected Game game;
   6:     protected HashMap values;
   7:     protected JPanel moreTags;
   8:         ...
   9: 
  10:         values = new HashMap();
  11: 
  12:         ...
  13: 
  14:             values.remove(tag.getKey());

View Full Code Here
   1: 
   2:     protected HashMap games;
   3: 
   4:         ...
   5:     players = new Hashtable();
   6:     games = new HashMap();
   7:     }
   8:         ...
   9: 
  10:     players.remove(pid);
  11: 
  12:         ...
  13:     p2.setGameId(g.getGameId());
  14:     games.remove("" + g.getGameId());

View Full Code Here
   1: 
   2:     public HashMap getPKUASProperties() {
   3:         ...
   4:         HashMap map = new HashMap();
   5:         Properties m_asProperties = loadPropFromFile(ConfigConstants.PKUASPROPERTIES);
   6:         ...
   7:                     + JNDIName);
   8:             map.remove("JNDIName");
   9:         }

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: 
   2:   HashMap seenModels, seenStmts, seenNs;
   3: 
   4:         ...
   5: 
   6:     seenModels = new HashMap();
   7:         ...
   8:     seenStmts = new HashMap();
   9:     seenNs = new HashMap();
  10:         ...
  11:     if(id == null)
  12:       seenModels.put(m, id = "m" + seenModels.size());

View Full Code Here
   1: 
   2:     private static HashMap      s_links = new HashMap();
   3:     static
   4:         ...
   5:     {
   6:         return s_links.size() != 0;
   7: 
   8:         ...
   9: {
  10:     Worker (String urlString, HashMap links)
  11:     {

View Full Code Here
   1: import java.util.ArrayList;
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:     private HashMap pendingMessages = new HashMap();
   7:     private Schedulable schedulable;
   8:         ...
   9:                   deltaT + "ms (Pending Messages=" +
  10:                   pendingMessages.size()+")" );
  11:             else if (deltaT >= infoTime)
  12:         ...
  13:                   deltaT + "ms (Pending Messages=" +
  14:                   pendingMessages.size()+")" );

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: 
   4:         ...
   5:         assertEquals("Incorrect number of attributes " + jobs[0].attrs, 1,
   6:             jobs[0].attrs.keySet().size());
   7:         assertEquals("Incorrect zone", "boot", jobs[0].attrs.get("zone"));
   8:         ...
   9:         assertEquals("Incorrect number of attributes", 2,
  10:             jobs[1].attrs.keySet().size());
  11:         assertEquals("Incorrect zone", "boot", jobs[1].attrs.get("zone"));
  12:         ...
  13:         assertEquals("Incorrect number of attributes", 1,
  14:             jobs[2].attrs.keySet().size());

View Full Code Here
   1: import java.util.ArrayList;
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5:     
   6:     HashMap changes = new HashMap();
   7:     
   8:         ...
   9:                 getAllTypesFromElement(cu, allTypes);
  10:                 for (int i = 0, length = allTypes.size(); i < length; i++) {
  11:                     IType type = (IType)allTypes.get(i);
  12:         ...
  13:                 getAllTypesFromHierarchy((JavaElement)cu, allTypes);
  14:                 for (int i = 0, length = allTypes.size(); i < length; i++) {

View Full Code Here

values

public Collection values()
Returns a collection view of the values contained in this map. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from this map, via 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: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: {
   6:    private HashMap m_map = new HashMap();
   7: 
   8:         ...
   9:    {
  10:       return m_map.values().iterator();
  11:    }

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:     private HashMap elements = new HashMap();
   7: 
   8:         ...
   9:     public Iterator getElements() {
  10:         return elements.values().iterator();
  11:     }

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:     private HashMap elements = new HashMap();
   7: 
   8:         ...
   9:     public Iterator getElements() {
  10:         return elements.values().iterator();
  11:     }

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: 
   6:     private HashMap elements = new HashMap();
   7: 
   8:         ...
   9:     public Iterator getElements() {
  10:         return elements.values().iterator();
  11:     }

View Full Code Here
   1: 
   2: import java.util.HashMap;
   3: import java.util.Iterator;
   4:         ...
   5: public class ServletDefinitionListImpl implements ServletDefinitionList {
   6:     private HashMap definitions = new HashMap();
   7:     
   8:         ...
   9:     public Iterator iterator() {
  10:         return definitions.values().iterator();
  11:     }

View Full Code Here