White Tour 15

A. Set

The disorder can not be repeated

Disorder: storage order and get a different order

HashSet: data structure is a hash table

TreeSet: binary tree

Two. Map

One to one mapping between (key-value pairs)

Unique key value may be repeated

2.1 Create

format:

Map <key type, value type> set name = new HashMap <> ();

2.2 common method

1, put (e1, e2): The e1, e2 form a key to the storage to the collection; e1 if the key does not exist, null is returned, otherwise, the return value is covered

2, remove (key): the key corresponding to the key deletion, the return value is deleted, if the key does not exist, return null

3, remove (key, value): holding a key in a map to find whether there is the key, if the key does not exist, false is returned delete failed; if this is the same key value exists and the key corresponding to the incoming value Removes and returns true, and vice versa false.

4, replace (key, value): If the key does not exist, or null replaced; if you will replace the old value of the value of this key

5, replace (key, oldValue, newValue): with logic remove (key, value), but the function performed is to replace the

6, get (key): Get values ​​corresponding to the key, this key does not exist return null

7、containValue(value)

8、containKey(key)

9、isEmpty()

10、clear()

11、size()

12, values ​​(): returns the value of a collection of Collection

13, a.putAll (b): The b added to a set of collection, if the key exists already covered

2.3 through the collection of

Guess you like

Origin www.cnblogs.com/demonycw/p/11329368.html