加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090218033529/http://developer.android.com:80/reference/java/util/Map.html
public interface

Map

java.util.Map<K, V>
Known Indirect Subclasses

Class Overview

Map has a set of keys, each key is mapped to a single value.

Summary

Nested Classes
public interface Map.Entry<K, V> Map.Entry is a key/value mapping which is contained in a Map. 
Public Methods
abstract void clear()
Removes all elements from this Map, leaving it empty.
abstract boolean containsKey(Object key)
Searches this Map for the specified key.
abstract boolean containsValue(Object value)
Searches this Map for the specified value.
abstract Set<Entry<K, V>> entrySet()
Returns a Set whose elements comprise all of the mappings that are to be found in this Map.
abstract boolean equals(Object object)
Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.
abstract V get(Object key)
Returns the value of the mapping with the specified key.
abstract int hashCode()
Returns an integer hash code for the receiver.
abstract boolean isEmpty()
Returns if this Map has no elements, a size of zero.
abstract Set<K> keySet()
Returns a Set of the keys contained in this Map.
abstract V put(K key, V value)
Maps the specified key to the specified value.
abstract void putAll(Map<? extends K, ? extends V> map)
Copies every mapping in the specified Map to this Map.
abstract V remove(Object key)
Removes a mapping with the specified key from this Map.
abstract int size()
Returns the number of elements in this Map.
abstract Collection<V> values()
Returns all of the current Map values in a Collection.

Public Methods

public abstract void clear ()

Removes all elements from this Map, leaving it empty.

Throws
UnsupportedOperationException when removing from this Map is not supported
See Also

public abstract boolean containsKey (Object key)

Searches this Map for the specified key.

Parameters
key the object to search for
Returns
  • true if key is a key of this Map, false otherwise

public abstract boolean containsValue (Object value)

Searches this Map for the specified value.

Parameters
value the object to search for
Returns
  • true if value is a value of this Map, false otherwise

public abstract Set<Entry<K, V>> entrySet ()

Returns a Set whose elements comprise all of the mappings that are to be found in this Map. Information on each of the mappings is encapsulated in a separate Map.Entry instance. As the Set is backed by this Map, users should be aware that changes in one will be immediately visible in the other.

Returns
  • a Set of the mappings

public abstract boolean equals (Object object)

Compares the argument to the receiver, and returns true if they represent the same object using a class specific comparison.

Parameters
object Object the 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

public abstract V get (Object key)

Returns the value of the mapping with the specified key.

Parameters
key the key
Returns
  • the value of the mapping with the specified key

public abstract int hashCode ()

Returns an integer hash code for the receiver. Objects which are equal answer the same value for this method.

Returns
  • the receiver's hash
See Also

public abstract boolean isEmpty ()

Returns if this Map has no elements, a size of zero.

Returns
  • true if this Map has no elements, false otherwise
See Also

public abstract Set<K> keySet ()

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

Returns
  • a Set of the keys

public abstract V put (K key, V value)

Maps the specified key to the specified value.

Parameters
key the key
value the value
Returns
  • the value of any previous mapping with the specified key or null if there was no mapping
Throws
UnsupportedOperationException when adding to this Map is not supported
ClassCastException when the class of the key or value is inappropriate for this Map
IllegalArgumentException when the key or value cannot be added to this Map
NullPointerException when the key or value is null and this Map does not support null keys or values

public abstract void putAll (Map<? extends K, ? extends V> map)

Copies every mapping in the specified Map to this Map.

Parameters
map the Map to copy mappings from
Throws
UnsupportedOperationException when adding to this Map is not supported
ClassCastException when the class of a key or value is inappropriate for this Map
IllegalArgumentException when a key or value cannot be added to this Map
NullPointerException when a key or value is null and this Map does not support null keys or values

public abstract V remove (Object key)

Removes a mapping with the specified key from this Map.

Parameters
key the key of the mapping to remove
Returns
  • the value of the removed mapping or null if key is not a key in this Map
Throws
UnsupportedOperationException when removing from this Map is not supported

public abstract int size ()

Returns the number of elements in this Map.

Returns
  • the number of elements in this Map

public abstract Collection<V> values ()

Returns all of the current Map values in a Collection. As the returned Collection is backed by this Map, users should be aware that changes in one will be immediately visible in the other.

Returns
  • a Collection of the values