public class java.util.concurrent
ConcurrentSkipListMap<K, V>


Show All Login
Java SE 6
  
Extends: AbstractMap
Implements: ConcurrentNavigableMap, Cloneable, Serializable
Details
A scalable concurrent ConcurrentNavigableMap implementation. The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.

This class implements a concurrent variant of SkipLists providing expected average log(n) time cost for the containsKey, get, put and remove operations and their variants. Insertion, removal, update, and access operations safely execute concurrently by multiple threads. Iterators are weakly consistent, returning elements reflecting the state of the map at some point at or since the creation of the iterator. They do not throw ConcurrentModificationException, and may proceed concurrently with other operations. Ascending key ordered views and their iterators are faster than descending ones.

All Map.Entry pairs returned by methods in this class and its views represent snapshots of mappings at the time they were produced. They do not support the Entry.setValue method. (Note however that it is possible to change mappings in the associated map using put, putIfAbsent, or replace, depending on exactly which effect you need.)

Beware that, unlike in most collections, the size method is not a constant-time operation. Because of the asynchronous nature of these maps, determining the current number of elements requires a traversal of the elements. Additionally, the bulk operations putAll, equals, and clear are not guaranteed to be performed atomically. For example, an iterator operating concurrently with a putAll operation might view only some of the added elements.

This class and its views and iterators implement all of the optional methods of the Map and Iterator interfaces. Like most other concurrent collections, this class does not permit the use of null keys or values because some null return values cannot be reliably distinguished from the absence of elements.

This class is a member of the Java Collections Framework.
Kthe type of keys maintained by this map
Vthe type of mapped values
since1.6


Constructors
public ConcurrentSkipListMap()
Constructs a new, empty map, sorted according to the natural ordering of the keys.
public ConcurrentSkipListMap(Comparator comparator) Details
Constructs a new, empty map, sorted according to the specified comparator.
comparatorthe comparator that will be used to order this map. If null, the natural ordering of the keys will be used.
public ConcurrentSkipListMap(Map m) Details
Constructs a new map containing the same mappings as the given map, sorted according to the natural ordering of the keys.
mthe map whose mappings are to be placed in this map
ThrowsClassCastException: if the keys in m are not Comparable, or are not mutually comparable
ThrowsNullPointerException: if the specified map or any of its keys or values are null
public ConcurrentSkipListMap(SortedMap m) Details
Constructs a new map containing the same mappings and using the same ordering as the specified sorted map.
mthe sorted map whose mappings are to be placed in this map, and whose comparator is to be used to sort this map
ThrowsNullPointerException: if the specified sorted map or any of its keys or values are null

Methods
public Map.Entry ceilingEntry(Object key) Details
Returns a key-value mapping associated with the least key greater than or equal to the given key, or null if there is no such entry. The returned entry does not support the Entry.setValue method.
ThrowsClassCastException: if the specified key cannot be compared with the keys currently in the map
ThrowsNullPointerException: if the specified key is null
public Object ceilingKey(Object key) Details
ThrowsClassCastException: if the specified key cannot be compared with the keys currently in the map
ThrowsNullPointerException: if the specified key is null
public void clear()
Removes all of the mappings from this map.
public ConcurrentSkipListMap clone() Details
Returns a shallow copy of this ConcurrentSkipListMap instance. (The keys and values themselves are not cloned.)
returna shallow copy of this map
public Comparator comparator()
public boolean containsKey(Object key) Details
Returns true if this map contains a mapping for the specified key.
keykey whose presence in this map is to be tested
returntrue if this map contains a mapping for the specified key
ThrowsClassCastException: if the specified key cannot be compared with the keys currently in the map
ThrowsNullPointerException: if the specified key is null
public boolean containsValue(Object value) Details
Returns true if this map maps one or more keys to the specified value. This operation requires time linear in the map size.
valuevalue whose presence in this map is to be tested
returntrue if a mapping to value exists; false otherwise
ThrowsNullPointerException: if the specified value is null
public NavigableSet descendingKeySet()
public ConcurrentNavigableMap descendingMap()
public Set entrySet() Details
Returns a Set view of the mappings contained in this map. The set's iterator returns the entries in ascending key order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

The view's iterator is a "weakly consistent" iterator that will never throw ConcurrentModificationException, and guarantees to traverse elements as they existed upon construction of the iterator, and may (but is not guaranteed to) reflect any modifications subsequent to construction.

The Map.Entry elements returned by iterator.next() do not support the setValue operation.
returna set view of the mappings contained in this map, sorted in ascending key order

public boolean equals(Object o) Details
Compares the specified object with this map for equality. Returns true if the given object is also a map and the two maps represent the same mappings. More formally, two maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()). This operation may return misleading results if either map is concurrently modified during execution of this method.
oobject to be compared for equality with this map
returntrue if the specified object is equal to this map
public Map.Entry firstEntry()
Returns a key-value mapping associated with the least key in this map, or null if the map is empty. The returned entry does not support the Entry.setValue method.
public Object firstKey() Details
ThrowsNoSuchElementException: java.lang.NullPointerException at com.sun.tools.docserver.DocServlet.writeInlineTagString(DocServlet.java:1023) at com.sun.tools.docserver.DocServlet.writeTagPara(DocServlet.java:618) at com.sun.tools.docserver.DocServlet.writeDoc(DocServlet.java:547) at com.sun.tools.docserver.DocServlet.writeMethodTable(DocServlet.java:855) at com.sun.tools.docserver.DocServlet.processRequest(DocServlet.java:229) at com.sun.tools.docserver.DocServlet.doGet(DocServlet.java:742) at javax.servlet.http.HttpServlet.service(HttpServlet.java:734) at javax.servlet.http.HttpServlet.service(HttpServlet.java:847) at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:427) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:333) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at com.sun.tools.bui.Hit.doFilter(Hit.java:86) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:246) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:313) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:287) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:218) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593) at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:94) at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:98) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:222) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:166) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:648) at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:593) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:587) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:1096) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:288) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.invokeAdapter(DefaultProcessorTask.java:647) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.doProcess(DefaultProcessorTask.java:579) at com.sun.enterprise.web.connector.grizzly.DefaultProcessorTask.process(DefaultProcessorTask.java:831) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.executeProcessorTask(DefaultReadTask.java:341) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:263) at com.sun.enterprise.web.connector.grizzly.DefaultReadTask.doTask(DefaultReadTask.java:214) at com.sun.enterprise.web.portunif.PortUnificationPipeline$PUTask.doTask(PortUnificationPipeline.java:380) at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:265) at com.sun.enterprise.web.connector.grizzly.ssl.SSLWorkerThread.run(SSLWorkerThread.java:106)