![]() Returns a Collection view of the values contained in this HashMap. Returns the number of key-value mappings in this Map. Removes the mapping for this key from this HashMap if present. Of the keys currently in the specified Map. These mappings will replace any mappings that this HashMap had for any Returns a Set view of the keys contained in this HashMap.Īssociates the specified value with the specified key in this HashMap.Ĭopies all of the mappings from the specified Map to this HashMap Returns true if this Map contains no key-value mappings. ![]() Returns the value to which this HashMap maps the specified key. Returns a Collection view of the mappings contained in this HashMap. Returns true if this HashMap maps one or more keys to the specified Returns true if this HashMap contains a mapping for the specified key. Since: JDK1.2 See Also: Object.hashCode(),Ĭonstructs a new, empty HashMap with a default capacity and loadĬonstructs a new, empty HashMap with the specified initialĬonstructs a new, empty HashMap with the specified initial capacityĬonstructs a new HashMap with the same mappings as the given Risking arbitrary, non-deterministic behavior at an undetermined time in the Thus, in the face ofĬoncurrent modification, the Iterator fails quickly and cleanly, rather than Iterator will throw a ConcurrentModificationException. In any way except through the Iterator's own remove or add methods, the HashMap is structurally modified at any time after the Iterator is created, The Iterators returned by the iterator methods of the Collections returnedīy all of HashMap's "collection view methods" are fail-fast: if the Map m = Collections.synchronizedMap(new HashMap(.)) This is best done at creation time, to prevent accidental The HashMap should be "wrapped" using the Collections.synchronizedMap Object that naturally encapsulates the HashMap. Modification.) This is typically accomplished by synchronizing on some With a key that is already contained in the Table is not a structural (A structural modification is any operation that adds orĭeletes one or more mappings merely changing the value associated Threads modifies the HashMap structurally, it must be synchronizedĮxternally. ![]() Multiple threads access a HashMap concurrently, and at least one of the Note that this implementation is not synchronized. Sufficiently large capacity will allow the mappings to be stored moreĮfficiently than letting it perform automatic rehashing as needed to grow If many mappings are to be stored in a HashMap, creating it with a Load factors use memory more efficiently, at the expense of larger expected The HashMap exceeds the product of the load factor and the currentĬapacity, the capacity is increased by calling the rehash method. The load factor should beīetween 0.0 (exclusive) and 1.0 (inclusive). Low) if iteration performance is important.Īn instance of HashMap has two parameters that affect its efficiency: itsĬapacity and its load factor. Important not to set the intial capacity too high (or the load factor too Requires time proportional to the "capacity" of the HashMap (the number ofīuckets) plus its size (the number of key-value mappings). Operations (get and put), assuming the the hash function disperses theĮlements properly among the buckets. This implementation provides constant-time performance for the basic The order of the Map in particular, it does not guarantee that the order Is unsynchronized and permits nulls.) This class makes no guarantees as to (HashMap is roughly equivalent to Hashtable, except that it Provides all of the optional Map operations, and permits null values and Hash table based implementation of the Map interface. Public class HashMap extends AbstractMap implements Map, Cloneable, Serializable
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |