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

Classes

class  SimpleEntry
 
class  SimpleImmutableEntry
 

Public Member Functions

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)
 

Protected Member Functions

Object clone () throws CloneNotSupportedException
 

Detailed Description

A base class for

Map

implementations.

Subclasses that permit new mappings to be added must override put.

The default implementations of many methods are inefficient for large maps. For example in the default implementation, each call to get performs a linear iteration of the entry set. Subclasses should override such methods to improve their performance.

Since
1.2

Member Function Documentation

◆ clear()

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

Removes all elements from this

Map

, leaving it empty.

Exceptions
UnsupportedOperationExceptionif removing elements from this
Map
is not supported.
See also
isEmpty()
size()

This implementation calls

entrySet().clear()

.

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

◆ containsKey()

boolean java.util.AbstractMap< 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.

This implementation iterates its key set, looking for a key that

key

equals.

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

◆ containsValue()

boolean java.util.AbstractMap< 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.

This implementation iterates its entry set, looking for an entry with a value that

value

equals.

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

◆ entrySet()

abstract Set<Map.Entry<K, V> > java.util.AbstractMap< K, V >.entrySet ( )
abstract

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 >.

◆ equals()

boolean java.util.AbstractMap< K, V >.equals ( Object  object)
inline

Compares the argument to the receiver, and returns

true

if the specified object is a

Map

and both

Map

s contain the same mappings.

Parameters
objectthe
Object
to compare with this
Object
.
Returns
boolean
true
if the
Object
is the same as this
Object
false
if it is different from this
Object
.
See also
hashCode()
entrySet()

This implementation first checks the structure of

object

. If it is not a map or of a different size, this returns false. Otherwise it iterates its own entry set, looking up each entry's key in

object

. If any value does not equal the other map's value for the same key, this returns false. Otherwise it returns true.

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

◆ get()

V java.util.AbstractMap< 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.

This implementation iterates its entry set, looking for an entry with a key that

key

equals.

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

◆ hashCode()

int java.util.AbstractMap< K, V >.hashCode ( )
inline

Returns an integer hash code for the receiver.

Object

s which are equal return the same value for this method.

Returns
the receiver's hash.
See also
equals(Object)

This implementation iterates its entry set, summing the hashcodes of its entries.

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

◆ isEmpty()

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

Returns whether this map is empty.

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

This implementation compares

size()

to 0.

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

◆ keySet()

Set<K> java.util.AbstractMap< 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.

This implementation returns a view that calls through this to map. Its iterator transforms this map's entry set iterator to return keys.

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

◆ put()

V java.util.AbstractMap< 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 mapping.
Exceptions
UnsupportedOperationExceptionif adding to this
Map
is not supported.
ClassCastExceptionif the class of the key or value is inappropriate for this
Map
.
IllegalArgumentExceptionif the key or value cannot be added to this
Map
.
NullPointerExceptionif the key or value is
null
and this
Map
does not support
null
keys or values.

This base implementation throws

UnsupportedOperationException

.

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

◆ putAll()

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

This implementation iterates through

map

's entry set, calling

put()

for each.

◆ remove()

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

Removes a 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.
Exceptions
UnsupportedOperationExceptionif removing from this
Map
is not supported.

This implementation iterates its entry set, removing the entry with a key that

key

equals.

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

◆ size()

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

Returns the number of mappings in this

Map

.

Returns
the number of mappings in this
Map
.

This implementation returns its entry set's size.

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

◆ toString()

String java.util.AbstractMap< K, V >.toString ( )
inline

This implementation composes a string by iterating its entry set. If this map contains itself as a key or a value, the string "(this Map)" will appear in its place.

◆ values()

Collection<V> java.util.AbstractMap< 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 Collection#remove, Collection#removeAll, Collection#retainAll, and Collection#clear operations, and it does not support Collection#add or Collection#addAll operations. This method returns a

Collection

which is the subclass of AbstractCollection. The AbstractCollection#iterator method of this subclass returns a "wrapper object" over the iterator of this

Map

's entrySet(). The AbstractCollection#size method wraps this

Map

's size method and the AbstractCollection#contains method wraps this

Map

's containsValue method. The collection is created when this method is called at first time and returned in response to all subsequent calls. This method may return different Collection when multiple calls to this method, since it has no synchronization performed.

Returns
a collection of the values contained in this map.

This implementation returns a view that calls through this to map. Its iterator transforms this map's entry set iterator to return values.

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


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