java collections: Map

java collections: Map

Inheritance

Map

  • Map isMapping interface, The content is stored in the MapKey-value pairs(key-value),Map map can not contain duplicate keys; each key can only be mapped to a value at most
  • Map's implementation classes should provide two "standard" constructors:First, void (no argument) constructor, creates an empty mapSecond, the method is configured with a single argument of type Map, therewith for creating a parameter with the same key - new map value mappings.
  • Map provides interfaces are used to return a set of keys or a set of key values ​​- set value mappings.
  • the entrySet () Returns theKey - Value SetofSet collection
  • keySet () Returns theKeysetofSet collection
  • values ​​() returns the userValue SetofCollection collection
  • Because the Map can not contain duplicate keys; each key can only be mapped to a value at most. and so,Key - value set, the key set is Set, the value of the collection Collection

Entry

  • Map.Entry is an interface inside of the Map, Map.Entry isKey-value pairs, Map by the entrySet () Gets the value pairs Map.Entry set, thereby achieving the operation of the key value through the set.

AbstractMap

  • AbstractMap isMap inherited from an abstract class that implements most of the Map API
  • To achieve unmodifiable map, simply extend this class and provide implementations can entrySet method, which returns a mapping relationship set view map. Typically, the returned set will in turn be implemented on AbstractSet. This set does not support the add () or remove () method, the iterator does not support the remove () method.
  • To implement a modifiable map, you must put another override the methods of this class (or they will throw UnsupportedOperationException), entrySet (). Iterator () returns the iterator must additionally implement its remove method.

SortedMap

  • SortedMap is inherited Map interface. Content is SortedMapSort of key-value pairsSorting method is by a comparator (Comparator)
  • There are two types of SortedMap Sort by:Natural order OrUser specified comparator. Ordered insertion SortedMap all elements must implement Comparable interface (or designated comparator accepted).

NavigableMap

  • NavigableMap inherited from SortedMap interface. Compared to SortedMap, NavigableMap a series of navigation method; such as "greater than obtaining / object of certain other key", "key Get less than / equal to a certain object on the" like.

Dictionary

  • NavigableMap key JDK 1.0 is defined for the interface, including the basic functions of the operation keys.

Intelligent Recommendation

java collections and Map summary

1、List (ordered, repeatable) Object List is stored in an orderly, but also repeatable, List index is concerned, with a series of index and related methods, query speed. Because to list the collection ...

Map Java collections of

Map interpretation Map store a data structure of the object by key value. We've come in an array in the Map Object us to index their content indexed by subject by array index for the index object call...

Java collections -Map

[Statement] by reference herein from geek video College 1, a storage format: Save key-> value way example: snow -> 15806880888 2, commonly subclasses: HashMap: storage disorder, key allowed to r...

Java collections --Map

Map does not inherit the Collection interface that can be used to save data with a mapping relationship, which provides a key to value mapping. Thus, Map set values ​​stored in these two sets, one set...

Java Collections --Map Interface

Java Collections --Map Interface 1. Definitions Map data for the mapping relationship between the presence of <key, value> stored. Wherein, key value can not be repeated (using equals () method ...

More Recommendation

Java collections Collection / Map

1.Collection collection 2.Map collection 3. The operation set of tools Collections: Provides a number of methods to sort the elements set, query and modify, etc., also provides a set of immutable obje...

Map collection of collections in java

1. Background 1. The Map collection is widely used in actual development. Let's first talk about how to use the Map collection in the actual development and some knowledge points to pay attention to. ...

Overview of Map of Java Collections

In the article between, I gave a rough description of the collection. And understand the inheritance structure diagram of Collection based on single element storage in Java collection. Next we need to...

[Summary] Java collections (Map)

Map 01 / HashMap In JDK8, HashMap underlying a "linked list arrays + + red-black tree" implementation. In learning HashMap principle, we should focus its data structure, put the process, as ...

java foundation - Map Collections Collections framework

A, Map Collections Overview (In fact, it is to use a Map Set underlying collection.) Map Collection belonging to exist side by side and set in the frame Map storage is the key-value pairs Map storage ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top