ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/ConcurrentSkipListMap.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/ConcurrentSkipListMap.java (file contents):
Revision 1.5 by dl, Tue Mar 8 12:27:11 2005 UTC vs.
Revision 1.6 by dl, Tue Mar 22 01:30:18 2005 UTC

# Line 11 | Line 11 | import java.util.concurrent.atomic.*;
11   /**
12   * A scalable {@link ConcurrentNavigableMap} implementation.  This
13   * class maintains a map in ascending key order, sorted according to
14 < * the <i>natural order</i> for the key's class (see {@link
14 > * the <i>natural order</i> for the keys' class (see {@link
15   * Comparable}), or by the {@link Comparator} provided at creation
16   * time, depending on which constructor is used.
17   *
# Line 1801 | Line 1801 | public class ConcurrentSkipListMap<K,V>
1801      }
1802  
1803      /**
1804 <     * Returns the number of elements in this map.  If this map
1804 >     * Returns the number of key-value mappings in this map.  If this map
1805       * contains more than <tt>Integer.MAX_VALUE</tt> elements, it
1806       * returns <tt>Integer.MAX_VALUE</tt>.
1807       *
# Line 2186 | Line 2186 | public class ConcurrentSkipListMap<K,V>
2186      /**
2187       * Returns a view of the portion of this map whose keys range from
2188       * <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive.  (If
2189 <     * <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned sorted map
2190 <     * is empty.)  The returned sorted map is backed by this map, so changes
2191 <     * in the returned sorted map are reflected in this map, and vice-versa.
2189 >     * <tt>fromKey</tt> and <tt>toKey</tt> are equal, the returned navigable map
2190 >     * is empty.)  The returned navigable map is backed by this map, so changes
2191 >     * in the returned navigable map are reflected in this map, and vice-versa.
2192  
2193       * @param fromKey low endpoint (inclusive) of the subMap.
2194       * @param toKey high endpoint (exclusive) of the subMap.
# Line 2204 | Line 2204 | public class ConcurrentSkipListMap<K,V>
2204       * @throws NullPointerException if <tt>fromKey</tt> or <tt>toKey</tt> is
2205       *               <tt>null</tt>.
2206       */
2207 <    public ConcurrentNavigableMap<K,V> subMap(K fromKey, K toKey) {
2207 >    public ConcurrentNavigableMap<K,V> navigableSubMap(K fromKey, K toKey) {
2208          if (fromKey == null || toKey == null)
2209              throw new NullPointerException();
2210          return new ConcurrentSkipListSubMap(this, fromKey, toKey);
# Line 2212 | Line 2212 | public class ConcurrentSkipListMap<K,V>
2212  
2213      /**
2214       * Returns a view of the portion of this map whose keys are
2215 <     * strictly less than <tt>toKey</tt>.  The returned sorted map is
2216 <     * backed by this map, so changes in the returned sorted map are
2215 >     * strictly less than <tt>toKey</tt>.  The returned navigable map is
2216 >     * backed by this map, so changes in the returned navigable map are
2217       * reflected in this map, and vice-versa.
2218       * @param toKey high endpoint (exclusive) of the headMap.
2219       * @return a view of the portion of this map whose keys are
# Line 2224 | Line 2224 | public class ConcurrentSkipListMap<K,V>
2224       * if <tt>toKey</tt> does not implement <tt>Comparable</tt>).
2225       * @throws NullPointerException if <tt>toKey</tt> is <tt>null</tt>.
2226       */
2227 <    public ConcurrentNavigableMap<K,V> headMap(K toKey) {
2227 >    public ConcurrentNavigableMap<K,V> navigableHeadMap(K toKey) {
2228          if (toKey == null)
2229              throw new NullPointerException();
2230          return new ConcurrentSkipListSubMap(this, null, toKey);
# Line 2232 | Line 2232 | public class ConcurrentSkipListMap<K,V>
2232  
2233      /**
2234       * Returns a view of the portion of this map whose keys are
2235 <     * greater than or equal to <tt>fromKey</tt>.  The returned sorted
2236 <     * map is backed by this map, so changes in the returned sorted
2235 >     * greater than or equal to <tt>fromKey</tt>.  The returned navigable
2236 >     * map is backed by this map, so changes in the returned navigable
2237       * map are reflected in this map, and vice-versa.
2238       * @param fromKey low endpoint (inclusive) of the tailMap.
2239       * @return a view of the portion of this map whose keys are
# Line 2244 | Line 2244 | public class ConcurrentSkipListMap<K,V>
2244       * <tt>Comparable</tt>).
2245       * @throws NullPointerException if <tt>fromKey</tt> is <tt>null</tt>.
2246       */
2247 <    public ConcurrentNavigableMap<K,V>  tailMap(K fromKey) {
2247 >    public ConcurrentNavigableMap<K,V>  navigableTailMap(K fromKey) {
2248 >        if (fromKey == null)
2249 >            throw new NullPointerException();
2250 >        return new ConcurrentSkipListSubMap(this, fromKey, null);
2251 >    }
2252 >
2253 >
2254 >    /**
2255 >     * Equivalent to <tt>navigableSubMap</tt> but with a return
2256 >     * type conforming to the <tt>SortedMap</tt> interface.
2257 >     * @param fromKey low endpoint (inclusive) of the subMap.
2258 >     * @param toKey high endpoint (exclusive) of the subMap.
2259 >     *
2260 >     * @return a view of the portion of this map whose keys range from
2261 >     * <tt>fromKey</tt>, inclusive, to <tt>toKey</tt>, exclusive.
2262 >     *
2263 >     * @throws ClassCastException if <tt>fromKey</tt> and <tt>toKey</tt>
2264 >     *         cannot be compared to one another using this map's comparator
2265 >     *         (or, if the map has no comparator, using natural ordering).
2266 >     * @throws IllegalArgumentException if <tt>fromKey</tt> is greater than
2267 >     *         <tt>toKey</tt>.
2268 >     * @throws NullPointerException if <tt>fromKey</tt> or <tt>toKey</tt> is
2269 >     *               <tt>null</tt>.
2270 >     */
2271 >    public SortedMap<K,V> subMap(K fromKey, K toKey) {
2272 >        if (fromKey == null || toKey == null)
2273 >            throw new NullPointerException();
2274 >        return new ConcurrentSkipListSubMap(this, fromKey, toKey);
2275 >    }
2276 >
2277 >    /**
2278 >     * Equivalent to <tt>navigableHeadMap</tt> but with a return
2279 >     * type conforming to the <tt>SortedMap</tt> interface.
2280 >     * @param toKey high endpoint (exclusive) of the headMap.
2281 >     * @return a view of the portion of this map whose keys are
2282 >     * strictly less than <tt>toKey</tt>.
2283 >     *
2284 >     * @throws ClassCastException if <tt>toKey</tt> is not compatible
2285 >     * with this map's comparator (or, if the map has no comparator,
2286 >     * if <tt>toKey</tt> does not implement <tt>Comparable</tt>).
2287 >     * @throws NullPointerException if <tt>toKey</tt> is <tt>null</tt>.
2288 >     */
2289 >    public SortedMap<K,V> headMap(K toKey) {
2290 >        if (toKey == null)
2291 >            throw new NullPointerException();
2292 >        return new ConcurrentSkipListSubMap(this, null, toKey);
2293 >    }
2294 >
2295 >    /**
2296 >     * Equivalent to <tt>navigableTailMap</tt> but with a return
2297 >     * type conforming to the <tt>SortedMap</tt> interface.
2298 >     * @param fromKey low endpoint (inclusive) of the tailMap.
2299 >     * @return a view of the portion of this map whose keys are
2300 >     * greater than or equal to <tt>fromKey</tt>.
2301 >     * @throws ClassCastException if <tt>fromKey</tt> is not
2302 >     * compatible with this map's comparator (or, if the map has no
2303 >     * comparator, if <tt>fromKey</tt> does not implement
2304 >     * <tt>Comparable</tt>).
2305 >     * @throws NullPointerException if <tt>fromKey</tt> is <tt>null</tt>.
2306 >     */
2307 >    public SortedMap<K,V>  tailMap(K fromKey) {
2308          if (fromKey == null)
2309              throw new NullPointerException();
2310          return new ConcurrentSkipListSubMap(this, fromKey, null);
# Line 3163 | Line 3223 | public class ConcurrentSkipListMap<K,V>
3223              throw new NoSuchElementException();
3224          }
3225  
3226 <        public ConcurrentNavigableMap<K,V> subMap(K fromKey, K toKey) {
3226 >        public ConcurrentNavigableMap<K,V> navigableSubMap(K fromKey, K toKey) {
3227              if (fromKey == null || toKey == null)
3228                  throw new NullPointerException();
3229              if (!inOpenRange(fromKey) || !inOpenRange(toKey))
# Line 3171 | Line 3231 | public class ConcurrentSkipListMap<K,V>
3231              return new ConcurrentSkipListSubMap(m, fromKey, toKey);
3232          }
3233  
3234 <        public ConcurrentNavigableMap<K,V> headMap(K toKey) {
3234 >        public ConcurrentNavigableMap<K,V> navigableHeadMap(K toKey) {
3235              if (toKey == null)
3236                  throw new NullPointerException();
3237              if (!inOpenRange(toKey))
# Line 3179 | Line 3239 | public class ConcurrentSkipListMap<K,V>
3239              return new ConcurrentSkipListSubMap(m, least, toKey);
3240          }
3241  
3242 <        public  ConcurrentNavigableMap<K,V> tailMap(K fromKey) {
3242 >        public  ConcurrentNavigableMap<K,V> navigableTailMap(K fromKey) {
3243              if (fromKey == null)
3244                  throw new NullPointerException();
3245              if (!inOpenRange(fromKey))
# Line 3187 | Line 3247 | public class ConcurrentSkipListMap<K,V>
3247              return new ConcurrentSkipListSubMap(m, fromKey, fence);
3248          }
3249  
3250 +        public SortedMap<K,V> subMap(K fromKey, K toKey) {
3251 +            return navigableSubMap(fromKey, toKey);
3252 +        }
3253 +
3254 +        public SortedMap<K,V> headMap(K toKey) {
3255 +            return navigableHeadMap(toKey);
3256 +        }
3257 +
3258 +        public  SortedMap<K,V> tailMap(K fromKey) {
3259 +            return navigableTailMap(fromKey);
3260 +        }
3261 +
3262          /* ----------------  Relational methods -------------- */
3263  
3264          public Map.Entry<K,V> ceilingEntry(K key) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines