DthingApi
Classes | Public Member Functions | List of all members
java.util.HashMap< K, V > Class Template Reference
Inheritance diagram for java.util.HashMap< K, V >:
java.util.AbstractMap< K, V > java.util.Map< K, V > java.io.Serializable java.util.Map< K, V > java.util.LinkedHashMap< K, V >

Classes

class  Entry
 
class  HashMapEntrySet
 

Public Member Functions

 HashMap ()
 
 HashMap (int capacity)
 
 HashMap (int capacity, float loadFactor)
 
 HashMap (Map<? extends K, ? extends V > map)
 
void clear ()
 
Object clone ()
 
boolean containsKey (Object key)
 
boolean containsValue (Object value)
 
Set< Map.Entry< K, V > > entrySet ()
 
get (Object key)
 
boolean isEmpty ()
 
Set< K > keySet ()
 
put (K key, V value)
 
void putAll (Map<? extends K, ? extends V > map)
 
remove (Object key)
 
int size ()
 
Collection< V > values ()
 
- Public Member Functions inherited from java.util.AbstractMap< K, V >
void clear ()
 
boolean containsKey (Object key)
 
boolean containsValue (Object value)
 
abstract Set< Map.Entry< K, V > > entrySet ()
 
boolean equals (Object object)
 
get (Object key)
 
int hashCode ()
 
boolean isEmpty ()
 
Set< K > keySet ()
 
put (K key, V value)
 
void putAll (Map<? extends K, ? extends V > map)
 
remove (Object key)
 
int size ()
 
String toString ()
 
Collection< V > values ()
 
- Public Member Functions inherited from java.util.Map< K, V >
void putAll (Map<? extends K,? extends V > map)
 

Additional Inherited Members

- Protected Member Functions inherited from java.util.AbstractMap< K, V >
Object clone () throws CloneNotSupportedException
 

Detailed Description

HashMap is an implementation of Map. All optional operations (adding and removing) are supported. Keys and values can be any objects.

Constructor & Destructor Documentation

◆ HashMap() [1/4]

java.util.HashMap< K, V >.HashMap ( )
inline

Constructs a new empty

instance.

◆ HashMap() [2/4]

java.util.HashMap< K, V >.HashMap ( int  capacity)
inline

Constructs a new

instance with the specified capacity.

Parameters
capacitythe initial capacity of this hash map.
Exceptions
IllegalArgumentExceptionwhen the capacity is less than zero.

◆ HashMap() [3/4]

java.util.HashMap< K, V >.HashMap ( int  capacity,
float  loadFactor 
)
inline

Constructs a new

instance with the specified capacity and load factor.

Parameters
capacitythe initial capacity of this hash map.
loadFactorthe initial load factor.
Exceptions
IllegalArgumentExceptionwhen the capacity is less than zero or the load factor is less or equal to zero.

◆ HashMap() [4/4]

java.util.HashMap< K, V >.HashMap ( Map<? extends K, ? extends V >  map)
inline

Constructs a new

instance containing the mappings from the specified map.

Parameters
mapthe mappings to add.

Member Function Documentation

◆ clear()

void java.util.HashMap< K, V >.clear ( )
inline

Removes all mappings from this hash map, leaving it empty.

See also
isEmpty
size

Implements java.util.Map< K, V >.

◆ clone()

Object java.util.HashMap< K, V >.clone ( )
inline

Returns a shallow copy of this map.

Returns
a shallow copy of this map.

◆ containsKey()

boolean java.util.HashMap< K, V >.containsKey ( Object  key)
inline

Returns whether this map contains the specified key.

Parameters
keythe key to search for.
Returns
true
if this map contains the specified key,
false
otherwise.

Implements java.util.Map< K, V >.

◆ containsValue()

boolean java.util.HashMap< K, V >.containsValue ( Object  value)
inline

Returns whether this map contains the specified value.

Parameters
valuethe value to search for.
Returns
true
if this map contains the specified value,
false
otherwise.

Implements java.util.Map< K, V >.

◆ entrySet()

Set<Map.Entry<K, V> > java.util.HashMap< K, V >.entrySet ( )
inline

Returns a set containing all of the mappings in this map. Each mapping is an instance of Map.Entry. As the set is backed by this map, changes in one will be reflected in the other.

Returns
a set of the mappings.

Implements java.util.Map< K, V >.

◆ get()

V java.util.HashMap< K, V >.get ( Object  key)
inline

Returns the value of the mapping with the specified key.

Parameters
keythe key.
Returns
the value of the mapping with the specified key, or
null
if no mapping for the specified key is found.

Implements java.util.Map< K, V >.

◆ isEmpty()

boolean java.util.HashMap< K, V >.isEmpty ( )
inline

Returns whether this map is empty.

Returns
true
if this map has no elements,
false
otherwise.
See also
size()

Implements java.util.Map< K, V >.

◆ keySet()

Set<K> java.util.HashMap< K, V >.keySet ( )
inline

Returns a set of the keys contained in this map. The set is backed by this map so changes to one are reflected by the other. The set does not support adding.

Returns
a set of the keys.

Implements java.util.Map< K, V >.

◆ put()

V java.util.HashMap< K, V >.put ( key,
value 
)
inline

Maps the specified key to the specified value.

Parameters
keythe key.
valuethe value.
Returns
the value of any previous mapping with the specified key or
null
if there was no such mapping.

Implements java.util.Map< K, V >.

◆ putAll()

void java.util.HashMap< K, V >.putAll ( Map<? extends K, ? extends V >  map)
inline

Copies all the mappings in the specified map to this map. These mappings will replace all mappings that this map had for any of the keys currently in the given map.

Parameters
mapthe map to copy mappings from.
Exceptions
NullPointerExceptionif
map
is
null
.

◆ remove()

V java.util.HashMap< K, V >.remove ( Object  key)
inline

Removes the mapping with the specified key from this map.

Parameters
keythe key of the mapping to remove.
Returns
the value of the removed mapping or
null
if no mapping for the specified key was found.

Implements java.util.Map< K, V >.

◆ size()

int java.util.HashMap< K, V >.size ( )
inline

Returns the number of elements in this map.

Returns
the number of elements in this map.

Implements java.util.Map< K, V >.

◆ values()

Collection<V> java.util.HashMap< K, V >.values ( )
inline

Returns a collection of the values contained in this map. The collection is backed by this map so changes to one are reflected by the other. The collection supports remove, removeAll, retainAll and clear operations, and it does not support add or addAll operations.

This method returns a collection which is the subclass of AbstractCollection. The iterator method of this subclass returns a "wrapper object" over the iterator of map's entrySet(). The

method wraps the map's size method and the

contains

method wraps the map's containsValue method.

The collection is created when this method is called for the first time and returned in response to all subsequent calls. This method may return different collections when multiple concurrent calls occur, since no synchronization is performed.

Returns
a collection of the values contained in this map.

Implements java.util.Map< K, V >.


The documentation for this class was generated from the following file: