22-其他说明
其他说明
ConcurrentSkipListMap
类还有其他有趣的方法,如下所示。
headMap(K toKey):K
是与ConcurrentSkipListMap
中的key值相对应的泛型参数。该方法返回一个从首个元素到小于toKey的元素的subMap。tailMap(K fromKey)
:K
是与ConcurrentSkipListMap
中的key值相对应的泛型参数。该方法返回一个从fromKey值元素到最后一个元素的subMap。putIfAbsent(K key, V value)
:该方法会插入一个key和value参数到map中,其前提是该map不存在将要插入的key。pollLastEntry()
:该方法会返回并移除map中的最后一个Map.Entry
对象元素。replace(K key, V value)
:该方法会替换与key参数相关联的value值,其前提是该key已存在于map中。