Java Doc for ConcurrentSkipListMap.java in  » 6.0-JDK-Core » Collections-Jar-Zip-Logging-regex » java » util » concurrent » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
Java Source Code / Java Documentation
1.6.0 JDK Core
2.6.0 JDK Modules
3.6.0 JDK Modules com.sun
4.6.0 JDK Modules com.sun.java
5.6.0 JDK Modules sun
6.6.0 JDK Platform
7.Ajax
8.Apache Harmony Java SE
9.Aspect oriented
10.Authentication Authorization
11.Blogger System
12.Build
13.Byte Code
14.Cache
15.Chart
16.Chat
17.Code Analyzer
18.Collaboration
19.Content Management System
20.Database Client
21.Database DBMS
22.Database JDBC Connection Pool
23.Database ORM
24.Development
25.EJB Server
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » Collections Jar Zip Logging regex » java.util.concurrent 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.util.concurrent.ConcurrentSkipListMap

ConcurrentSkipListMap
public class ConcurrentSkipListMap extends AbstractMap implements ConcurrentNavigableMap<K, V>,Cloneable,java.io.Serializable(Code)
A scalable concurrent ConcurrentNavigableMap implementation. The map is sorted according to the 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.
author:
   Doug Lea<
Parameters:
  K - > the type of keys maintained by this map<
Parameters:
  V - > the type of mapped values
since:
   1.6


Inner Class :final static class Node
Inner Class :static class Index
Inner Class :final static class HeadIndex extends Index
Inner Class :final static class ComparableUsingComparator implements Comparable<K>
Inner Class :abstract class Iter implements Iterator<T>
Inner Class :final class ValueIterator extends Iter
Inner Class :final class KeyIterator extends Iter
Inner Class :final class EntryIterator extends Iter>
Inner Class :final static class KeySet extends AbstractSet implements NavigableSet<E>
Inner Class :final static class Values extends AbstractCollection
Inner Class :final static class EntrySet extends AbstractSet>
Inner Class :final static class SubMap extends AbstractMap implements ConcurrentNavigableMap<K, V>,Cloneable,java.io.Serializable


Constructor Summary
public  ConcurrentSkipListMap()
     Constructs a new, empty map, sorted according to the of the keys.
public  ConcurrentSkipListMap(Comparator<? super K> comparator)
     Constructs a new, empty map, sorted according to the specified comparator.
public  ConcurrentSkipListMap(Map<? extends K, ? extends V> m)
     Constructs a new map containing the same mappings as the given map, sorted according to the of the keys.
public  ConcurrentSkipListMap(SortedMap<K, ? extends V> m)
     Constructs a new map containing the same mappings and using the same ordering as the specified sorted map.

Method Summary
public  Map.Entry<K, V>ceilingEntry(K key)
     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.
public  KceilingKey(K key)
    
public  voidclear()
     Removes all of the mappings from this map.
public  ConcurrentSkipListMap<K, V>clone()
     Returns a shallow copy of this ConcurrentSkipListMap instance.
public  Comparator<? super K>comparator()
    
 intcompare(K k1, K k2)
     Compares using comparator or natural ordering.
public  booleancontainsKey(Object key)
     Returns true if this map contains a mapping for the specified key.
public  booleancontainsValue(Object value)
     Returns true if this map maps one or more keys to the specified value.
public  NavigableSet<K>descendingKeySet()
    
public  ConcurrentNavigableMap<K, V>descendingMap()
    
final  VdoRemove(Object okey, Object value)
     Main deletion method.
 Map.Entry<K, V>doRemoveFirstEntry()
     Removes first entry; returns its snapshot.
 Map.Entry<K, V>doRemoveLastEntry()
     Removes last entry; returns its snapshot.
 Iterator<Map.Entry<K, V>>entryIterator()
    
public  Set<Map.Entry<K, V>>entrySet()
     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.
public  booleanequals(Object o)
     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.
 Node<K, V>findFirst()
     Specialized variant of findNode to get first valid node.
 Node<K, V>findLast()
     Specialized version of find to get last valid node.
 Node<K, V>findNear(K kkey, int rel)
     Utility for ceiling, floor, lower, higher methods.
public  Map.Entry<K, V>firstEntry()
     Returns a key-value mapping associated with the least key in this map, or null if the map is empty.
public  KfirstKey()
    
public  Map.Entry<K, V>floorEntry(K key)
     Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key.
public  KfloorKey(K key)
    
public  Vget(Object key)
     Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
 AbstractMap.SimpleImmutableEntry<K, V>getNear(K key, int rel)
     Returns SimpleImmutableEntry for results of findNear.
public  ConcurrentNavigableMap<K, V>headMap(K toKey, boolean inclusive)
    
public  ConcurrentNavigableMap<K, V>headMap(K toKey)
    
public  Map.Entry<K, V>higherEntry(K key)
     Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key.
public  KhigherKey(K key)
    
 booleaninHalfOpenRange(K key, K least, K fence)
     Returns true if given key greater than or equal to least and strictly less than fence, bypassing either test if least or fence are null.
 booleaninOpenRange(K key, K least, K fence)
     Returns true if given key greater than or equal to least and less or equal to fence.
final  voidinitialize()
     Initializes or resets state.
public  booleanisEmpty()
     Returns true if this map contains no key-value mappings.
 Iterator<K>keyIterator()
    
public  NavigableSet<K>keySet()
     Returns a NavigableSet view of the keys contained in this map. The set's iterator returns the keys in ascending order. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa.
public  Map.Entry<K, V>lastEntry()
     Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
public  KlastKey()
    
public  Map.Entry<K, V>lowerEntry(K key)
     Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key.
public  KlowerKey(K key)
    
public  NavigableSet<K>navigableKeySet()
    
public  Map.Entry<K, V>pollFirstEntry()
     Removes and returns a key-value mapping associated with the least key in this map, or null if the map is empty.
public  Map.Entry<K, V>pollLastEntry()
     Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty.
public  Vput(K key, V value)
     Associates the specified value with the specified key in this map.
public  VputIfAbsent(K key, V value)
    
public  Vremove(Object key)
     Removes the mapping for the specified key from this map if present.
public  booleanremove(Object key, Object value)
    
public  booleanreplace(K key, V oldValue, V newValue)
    
public  Vreplace(K key, V value)
    
public  intsize()
     Returns the number of key-value mappings in this map.
public  ConcurrentNavigableMap<K, V>subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)
    
public  ConcurrentNavigableMap<K, V>subMap(K fromKey, K toKey)
    
public  ConcurrentNavigableMap<K, V>tailMap(K fromKey, boolean inclusive)
    
public  ConcurrentNavigableMap<K, V>tailMap(K fromKey)
    
final static  List<E>toList(Collection<E> c)
    
 Iterator<V>valueIterator()
    
public  Collection<V>values()
     Returns a Collection view of the values contained in this map. The collection's iterator returns the values in ascending order of the corresponding keys. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa.


Constructor Detail
ConcurrentSkipListMap
public ConcurrentSkipListMap()(Code)
Constructs a new, empty map, sorted according to the of the keys.



ConcurrentSkipListMap
public ConcurrentSkipListMap(Comparator<? super K> comparator)(Code)
Constructs a new, empty map, sorted according to the specified comparator.
Parameters:
  comparator - the comparator that will be used to order this map.If null, the of the keys will be used.



ConcurrentSkipListMap
public ConcurrentSkipListMap(Map<? extends K, ? extends V> m)(Code)
Constructs a new map containing the same mappings as the given map, sorted according to the of the keys.
Parameters:
  m - the map whose mappings are to be placed in this map
throws:
  ClassCastException - if the keys in m are notComparable, or are not mutually comparable
throws:
  NullPointerException - if the specified map or any of its keysor values are null



ConcurrentSkipListMap
public ConcurrentSkipListMap(SortedMap<K, ? extends V> m)(Code)
Constructs a new map containing the same mappings and using the same ordering as the specified sorted map.
Parameters:
  m - the sorted map whose mappings are to be placed in thismap, and whose comparator is to be used to sort this map
throws:
  NullPointerException - if the specified sorted map or any ofits keys or values are null




Method Detail
ceilingEntry
public Map.Entry<K, V> ceilingEntry(K key)(Code)
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.
throws:
  ClassCastException -
throws:
  NullPointerException - if the specified key is null



ceilingKey
public K ceilingKey(K key)(Code)

throws:
  ClassCastException -
throws:
  NullPointerException - if the specified key is null



clear
public void clear()(Code)
Removes all of the mappings from this map.



clone
public ConcurrentSkipListMap<K, V> clone()(Code)
Returns a shallow copy of this ConcurrentSkipListMap instance. (The keys and values themselves are not cloned.) a shallow copy of this map



comparator
public Comparator<? super K> comparator()(Code)



compare
int compare(K k1, K k2) throws ClassCastException(Code)
Compares using comparator or natural ordering. Used when the ComparableUsingComparator approach doesn't apply.



containsKey
public boolean containsKey(Object key)(Code)
Returns true if this map contains a mapping for the specified key.
Parameters:
  key - key whose presence in this map is to be tested true if this map contains a mapping for the specified key
throws:
  ClassCastException - if the specified key cannot be comparedwith the keys currently in the map
throws:
  NullPointerException - if the specified key is null



containsValue
public boolean containsValue(Object value)(Code)
Returns true if this map maps one or more keys to the specified value. This operation requires time linear in the map size.
Parameters:
  value - value whose presence in this map is to be tested true if a mapping to value exists;false otherwise
throws:
  NullPointerException - if the specified value is null



descendingKeySet
public NavigableSet<K> descendingKeySet()(Code)



descendingMap
public ConcurrentNavigableMap<K, V> descendingMap()(Code)



doRemove
final V doRemove(Object okey, Object value)(Code)
Main deletion method. Locates node, nulls value, appends a deletion marker, unlinks predecessor, removes associated index nodes, and possibly reduces head index level. Index nodes are cleared out simply by calling findPredecessor. which unlinks indexes to deleted nodes found along path to key, which will include the indexes to this node. This is done unconditionally. We can't check beforehand whether there are index nodes because it might be the case that some or all indexes hadn't been inserted yet for this node during initial search for it, and we'd like to ensure lack of garbage retention, so must call to be sure.
Parameters:
  okey - the key
Parameters:
  value - if non-null, the value that must beassociated with key the node, or null if not found



doRemoveFirstEntry
Map.Entry<K, V> doRemoveFirstEntry()(Code)
Removes first entry; returns its snapshot. null if empty, else snapshot of first entry



doRemoveLastEntry
Map.Entry<K, V> doRemoveLastEntry()(Code)
Removes last entry; returns its snapshot. Specialized variant of doRemove. null if empty, else snapshot of last entry



entryIterator
Iterator<Map.Entry<K, V>> entryIterator()(Code)



entrySet
public Set<Map.Entry<K, V>> entrySet()(Code)
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. a set view of the mappings contained in this map,sorted in ascending key order




equals
public boolean equals(Object o)(Code)
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.
Parameters:
  o - object to be compared for equality with this map true if the specified object is equal to this map



findFirst
Node<K, V> findFirst()(Code)
Specialized variant of findNode to get first valid node. first node or null if empty



findLast
Node<K, V> findLast()(Code)
Specialized version of find to get last valid node. last node or null if empty



findNear
Node<K, V> findNear(K kkey, int rel)(Code)
Utility for ceiling, floor, lower, higher methods.
Parameters:
  kkey - the key
Parameters:
  rel - the relation -- OR'ed combination of EQ, LT, GT nearest node fitting relation, or null if no such



firstEntry
public Map.Entry<K, V> firstEntry()(Code)
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.



firstKey
public K firstKey()(Code)

throws:
  NoSuchElementException -



floorEntry
public Map.Entry<K, V> floorEntry(K key)(Code)
Returns a key-value mapping associated with the greatest key less than or equal to the given key, or null if there is no such key. The returned entry does not support the Entry.setValue method.
Parameters:
  key - the key
throws:
  ClassCastException -
throws:
  NullPointerException - if the specified key is null



floorKey
public K floorKey(K key)(Code)

Parameters:
  key - the key
throws:
  ClassCastException -
throws:
  NullPointerException - if the specified key is null



get
public V get(Object key)(Code)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

More formally, if this map contains a mapping from a key k to a value v such that key compares equal to k according to the map's ordering, then this method returns v ; otherwise it returns null . (There can be at most one such mapping.)
throws:
  ClassCastException - if the specified key cannot be comparedwith the keys currently in the map
throws:
  NullPointerException - if the specified key is null




getNear
AbstractMap.SimpleImmutableEntry<K, V> getNear(K key, int rel)(Code)
Returns SimpleImmutableEntry for results of findNear.
Parameters:
  key - the key
Parameters:
  rel - the relation -- OR'ed combination of EQ, LT, GT Entry fitting relation, or null if no such



headMap
public ConcurrentNavigableMap<K, V> headMap(K toKey, boolean inclusive)(Code)

throws:
  ClassCastException -
throws:
  NullPointerException - if toKey is null
throws:
  IllegalArgumentException -



headMap
public ConcurrentNavigableMap<K, V> headMap(K toKey)(Code)

throws:
  ClassCastException -
throws:
  NullPointerException - if toKey is null
throws:
  IllegalArgumentException -



higherEntry
public Map.Entry<K, V> higherEntry(K key)(Code)
Returns a key-value mapping associated with the least key strictly greater than the given key, or null if there is no such key. The returned entry does not support the Entry.setValue method.
Parameters:
  key - the key
throws:
  ClassCastException -
throws:
  NullPointerException - if the specified key is null



higherKey
public K higherKey(K key)(Code)

Parameters:
  key - the key
throws:
  ClassCastException -
throws:
  NullPointerException - if the specified key is null



inHalfOpenRange
boolean inHalfOpenRange(K key, K least, K fence)(Code)
Returns true if given key greater than or equal to least and strictly less than fence, bypassing either test if least or fence are null. Needed mainly in submap operations.



inOpenRange
boolean inOpenRange(K key, K least, K fence)(Code)
Returns true if given key greater than or equal to least and less or equal to fence. Needed mainly in submap operations.



initialize
final void initialize()(Code)
Initializes or resets state. Needed by constructors, clone, clear, readObject. and ConcurrentSkipListSet.clone. (Note that comparator must be separately initialized.)



isEmpty
public boolean isEmpty()(Code)
Returns true if this map contains no key-value mappings. true if this map contains no key-value mappings



keyIterator
Iterator<K> keyIterator()(Code)



keySet
public NavigableSet<K> keySet()(Code)
Returns a NavigableSet view of the keys contained in this map. The set's iterator returns the keys in ascending 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.

This method is equivalent to method navigableKeySet . a navigable set view of the keys in this map




lastEntry
public Map.Entry<K, V> lastEntry()(Code)
Returns a key-value mapping associated with the greatest key in this map, or null if the map is empty. The returned entry does not support the Entry.setValue method.



lastKey
public K lastKey()(Code)

throws:
  NoSuchElementException -



lowerEntry
public Map.Entry<K, V> lowerEntry(K key)(Code)
Returns a key-value mapping associated with the greatest key strictly less than the given key, or null if there is no such key. The returned entry does not support the Entry.setValue method.
throws:
  ClassCastException -
throws:
  NullPointerException - if the specified key is null



lowerKey
public K lowerKey(K key)(Code)

throws:
  ClassCastException -
throws:
  NullPointerException - if the specified key is null



navigableKeySet
public NavigableSet<K> navigableKeySet()(Code)



pollFirstEntry
public Map.Entry<K, V> pollFirstEntry()(Code)
Removes and 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.



pollLastEntry
public Map.Entry<K, V> pollLastEntry()(Code)
Removes and returns a key-value mapping associated with the greatest key in this map, or null if the map is empty. The returned entry does not support the Entry.setValue method.



put
public V put(K key, V value)(Code)
Associates the specified value with the specified key in this map. If the map previously contained a mapping for the key, the old value is replaced.
Parameters:
  key - key with which the specified value is to be associated
Parameters:
  value - value to be associated with the specified key the previous value associated with the specified key, ornull if there was no mapping for the key
throws:
  ClassCastException - if the specified key cannot be comparedwith the keys currently in the map
throws:
  NullPointerException - if the specified key or value is null



putIfAbsent
public V putIfAbsent(K key, V value)(Code)
the previous value associated with the specified key,or null if there was no mapping for the key
throws:
  ClassCastException - if the specified key cannot be comparedwith the keys currently in the map
throws:
  NullPointerException - if the specified key or value is null



remove
public V remove(Object key)(Code)
Removes the mapping for the specified key from this map if present.
Parameters:
  key - key for which mapping should be removed the previous value associated with the specified key, ornull if there was no mapping for the key
throws:
  ClassCastException - if the specified key cannot be comparedwith the keys currently in the map
throws:
  NullPointerException - if the specified key is null



remove
public boolean remove(Object key, Object value)(Code)

throws:
  ClassCastException - if the specified key cannot be comparedwith the keys currently in the map
throws:
  NullPointerException - if the specified key is null



replace
public boolean replace(K key, V oldValue, V newValue)(Code)

throws:
  ClassCastException - if the specified key cannot be comparedwith the keys currently in the map
throws:
  NullPointerException - if any of the arguments are null



replace
public V replace(K key, V value)(Code)
the previous value associated with the specified key,or null if there was no mapping for the key
throws:
  ClassCastException - if the specified key cannot be comparedwith the keys currently in the map
throws:
  NullPointerException - if the specified key or value is null



size
public int size()(Code)
Returns the number of key-value mappings in this map. If this map contains more than Integer.MAX_VALUE elements, it returns Integer.MAX_VALUE.

Beware that, unlike in most collections, this method is NOT a constant-time operation. Because of the asynchronous nature of these maps, determining the current number of elements requires traversing them all to count them. Additionally, it is possible for the size to change during execution of this method, in which case the returned result will be inaccurate. Thus, this method is typically not very useful in concurrent applications. the number of elements in this map




subMap
public ConcurrentNavigableMap<K, V> subMap(K fromKey, boolean fromInclusive, K toKey, boolean toInclusive)(Code)

throws:
  ClassCastException -
throws:
  NullPointerException - if fromKey or toKey is null
throws:
  IllegalArgumentException -



subMap
public ConcurrentNavigableMap<K, V> subMap(K fromKey, K toKey)(Code)

throws:
  ClassCastException -
throws:
  NullPointerException - if fromKey or toKey is null
throws:
  IllegalArgumentException -



tailMap
public ConcurrentNavigableMap<K, V> tailMap(K fromKey, boolean inclusive)(Code)

throws:
  ClassCastException -
throws:
  NullPointerException - if fromKey is null
throws:
  IllegalArgumentException -



tailMap
public ConcurrentNavigableMap<K, V> tailMap(K fromKey)(Code)

throws:
  ClassCastException -
throws:
  NullPointerException - if fromKey is null
throws:
  IllegalArgumentException -



toList
final static List<E> toList(Collection<E> c)(Code)



valueIterator
Iterator<V> valueIterator()(Code)



values
public Collection<V> values()(Code)
Returns a Collection view of the values contained in this map. The collection's iterator returns the values in ascending order of the corresponding keys. The collection is backed by the map, so changes to the map are reflected in the collection, and vice-versa. The collection supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Collection.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.




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.