Set study------MAP

Source: Internet
Author: User

/* * Licensed to the Apache software Foundation (ASF) under one or more * Contributor license agreements. See the NOTICE file distributed with * This work for additional information regarding copyright ownership. * The ASF licenses this file to you under the Apache License, Version 2.0 * (the "License");  You are not a use of this file except in compliance with * the License. Obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * unless required by Applica BLE law or agreed into writing, software * Distributed under the License is distributed on a "as is" BASIS, * without Warranties or CONDITIONS of any KIND, either express OR implied. * See the License for the specific language governing permissions and * limitations under the License. */package java.util;/** * A {@code Map} is a data structure consisting of a set of keys and values * with which each key is  Mapped to a single value. The class of the objects * used as keys are declared when The {@code Map} is declared, as is the * class of the corresponding values. * <p> * A {@code Map} provides helper methods to iterate through all of the ' keys contained in it, as well as Vario US methods to access and update * The Key/value pairs.     */public interface Map<k,v> {/** * {@code map.entry} is a key/value mapping contained in a {@code Map}. */public static interface Entry<k,v> {/** * compares the specified object to this {@code map.en Try} and returns if they * is equal.         To be equal, the object must is an instance of {@code Map.entry} and has the * same key and value.         * * @param Object * The {@code object} to compare with this {@code object}.  * @return {@code true} if the specified {@code Object} is equal to this * {@code map.entry}, {@code false}         otherwise.        * @see #hashCode () */public Boolean equals (Object object);   /**      * Returns the key.        * * @return The key */public K getKey ();         /** * Returns the value.        * * @return The value */public V getValue (); /** * Returns An integer hash code for the receiver.         {@code Object} which is * equal return the same value for this method.         * * @return The receiver ' s hash code.        * @see #equals (Object) */public int hashcode ();         /** * Sets the value of this entry to the specified value, replacing any * existing value.         * * @param Object * The new value to set.         * @return Object The replaced value of this entry.    */Public v SetValue (v object);    };     /** * Removes all elements from this {@code Map}, leaving it empty. * * @throws unsupportedoperationexception * If removing elements from this {@code Map} are not Suppo  RTed.   * @see #isEmpty () * @see #size () */public void clear ();     /** * Returns Whether this {@code Map} contains the specified key.     * * @param key * The key to search for.     * @return {@code true} if this map contains the specified key, * {@code false} otherwise.    */Public Boolean containskey (Object key);     /** * Returns Whether this {@code Map} contains the specified value.     * * @param value * The value to search for.     * @return {@code true} if this map contains the specified value, * {@code false} otherwise.    */Public Boolean containsvalue (Object value); /** * Returns a {@code Set} containing all of the mappings in this {@code Map}. Each mapping are * An instance of {@link map.entry}.     As the {@code Set} is backed by this {@code Map}, * Changes in one would be reflected in the other. * * @return A set of the mappings */public Set<map.entry<k,v>> EntrySet (); /** * Compares the argument to the receiver, and returns {@code true} if the * specified object is a {@code Map} A     nd both {@code map}s contain the same mappings.     * * @param Object * The {@code object} to compare with this {@code object}. * @return Boolean {@code true} if the {@code Object} is the same as this {@code Object} * {@code false} if it     is different from this {@code Object}.    * @see #hashCode () * @see #entrySet () */public Boolean equals (Object object);     /** * Returns The value of the mapping with the specified key.     * * @param key * the key. * @return The value of the mapping with the specified key, or {@code null} * If no mapping for the specified k     EY is found.    */Public V get (Object key); /** * Returns An integer hash code for the receiver.     {@code object}s which is equal * return the same value for this method. * * @returnThe receiver ' s hash.    * @see #equals (Object) */public int hashcode ();     /** * Returns Whether this map is empty.     * * @return {@code true} if this map has no elements, {@code false} * otherwise.    * @see #size () */public Boolean isEmpty (); /** * Returns A set of the keys contained in this {@code Map}. The {@code Set} is backed by * This {@code Map} so changes to one was reflected by the other.     The {@code Set} does not * support adding.     * * @return A set of the keys.    */Public set<k> keySet ();     /** * Maps The specified key to the specified value.     * * @param key * the key.     * @param value * the value. * @return The value of any previous mapping with the specified key or * {@code null} If there is no mapping.     That is, return the value of the old (you are going to replace), if there is no such key, the return is null. * @throws Unsupportedoperationexception * If adding to this {@code Map} isNot supported.                * @throws ClassCastException * If the class of the key or value is inappropriate for *     This {@code Map}.     * @throws IllegalArgumentException * If the key or value cannot is added to this {@code Map}.                * @throws NullPointerException * If the key or value is {@code null} and this {@code Map} does * Not support {@code null} keys or values.
     * */Public V put (K key, v value);     /** * Copies Every mapping in the specified {@code map} to this {@code map}.     * * @param map * The {@code map} to copy mappings from.     * @throws Unsupportedoperationexception * If adding to this {@code Map} are not supported.                * @throws ClassCastException * If the class of a key or a value of the specified {@code Map} is *     Inappropriate for this {@code Map}.     * @throws IllegalArgumentException * If a key or value cannot is added to this {@code Map}.                * @throws NullPointerException * If a key or value is {@code null} and this {@code Map} does not *     Support {@code null} keys or values.    */public void Putall (map<? extends K,? extends v> Map);     /** * Removes a mapping with the specified key from this {@code Map}. * * @param key * The key of the mapPing to remove.     * @return The value of the removed mapping or {@code null} if no mapping * for the specified key is found.     * @throws unsupportedoperationexception * If removing from this {@code Map} are not supported.    */Public V Remove (Object key);     /** * Returns The number of mappings in this {@code Map}.     * * @return The number of mappings in this {@code Map}.    */public int size (); /** * Returns a {@code Collection} of the values contained in this {@code Map}. The {@code Collection} * is backed by this {@code Map} so changes to one was reflected by the other. The * {@code Collection} supports {@link collection#remove}, {@link Collection#removeall}, * {@link Collection#ret Ainall}, and {@link collection#clear} operations, * and it does not support {@link Collection#add} or {@link Collectio     N#addall} operations. * <p> * This method returns a {@code Collection} which is the subclass of    * {@link abstractcollection}.  The {@link Abstractcollection#iterator} method of this subclass returns a * ' wrapper object ' over the iterator of this {@code Map} ' s {@link #entrySet ()}. The {@link Abstractcollection#size} method * Wraps this {@code Map} ' s {@link #size} method and the {@link Abstractcoll     Ection#contains} method wraps this {@code Map} ' s * {@link #containsValue} method.  * <p> * The collection is created if this method was called at first time and * returned in response Subsequent calls. This method could return * different Collection when multiple calls to the This method, since it have no * synchronizatio     N performed.     * * @return A collection of the values contained in this map. */Public collection<v> values ();}

Set study------MAP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.