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.103 by jsr166, Mon Feb 18 03:15:10 2013 UTC vs.
Revision 1.104 by dl, Mon Feb 25 17:59:40 2013 UTC

# Line 3594 | Line 3594 | public class ConcurrentSkipListMap<K,V>
3594       * remaining number of elements of a skip list when advancing
3595       * either across or down decreases by about 25%. To make this
3596       * observation useful, we need to know initial size, which we
3597 <     * don't. But we use (1 << 2*levels) as a rough overestimate that
3598 <     * minimizes risk of prematurely zeroing out while splitting.
3597 >     * don't. But we can just use Integer.MAX_VALUE so that we
3598 >     * don't prematurely zero out while splitting.
3599       */
3600      static class CSLMSpliterator<K,V> {
3601          final Comparator<? super K> comparator;
# Line 3605 | Line 3605 | public class ConcurrentSkipListMap<K,V>
3605          int est;           // pseudo-size estimate
3606  
3607          CSLMSpliterator(ConcurrentSkipListMap<K,V> m) {
3608            HeadIndex<K,V> h; Node<K,V> p; int d, n; Index<K,V> hd;
3608              this.comparator = m.comparator;
3609              this.fence = null;
3610 <            for (;;) { // ensure h and n correspond to origin p
3610 >            for (;;) { // ensure h corresponds to origin p
3611 >                HeadIndex<K,V> h; Node<K,V> p;
3612                  Node<K,V> b = (h = m.head).node;
3613 <                if ((p = b.next) == null) {
3614 <                    n = 0;
3615 <                    break;
3616 <                }
3617 <                if (p.value != null) {
3618 <                    n = (d = h.level << 1) >= 31 ? Integer.MAX_VALUE : 1 << d;
3613 >                if ((p = b.next) == null || p.value != null) {
3614 >                    this.est = ((p == null) ? 0 :
3615 >                                (p.next == null) ? 1 : Integer.MAX_VALUE);
3616 >                    this.current = p;
3617 >                    this.row = h;
3618                      break;
3619                  }
3620                  p.helpDelete(b, p.next);
3621              }
3623            this.est = n;
3624            this.current = p;
3625            this.row = (h.right == null && (hd = h.down) != null) ? hd : h;
3622          }
3623  
3624          CSLMSpliterator(Comparator<? super K> comparator, Index<K,V> row,
# Line 3669 | Line 3665 | public class ConcurrentSkipListMap<K,V>
3665          }
3666  
3667          @SuppressWarnings("unchecked")
3668 <        public KeySpliterator<K,V> trySplit() {
3668 >        public Spliterator<K> trySplit() {
3669              Node<K,V> e;
3670              Comparator<? super K> cmp = comparator;
3671              K f = fence;
# Line 3758 | Line 3754 | public class ConcurrentSkipListMap<K,V>
3754          }
3755  
3756          @SuppressWarnings("unchecked")
3757 <        public ValueSpliterator<K,V> trySplit() {
3757 >        public Spliterator<V> trySplit() {
3758              Node<K,V> e;
3759              Comparator<? super K> cmp = comparator;
3760              K f = fence;
# Line 3845 | Line 3841 | public class ConcurrentSkipListMap<K,V>
3841          }
3842  
3843          @SuppressWarnings("unchecked")
3844 <        public EntrySpliterator<K,V> trySplit() {
3844 >        public Spliterator<Map.Entry<K,V>> trySplit() {
3845              Node<K,V> e;
3846              Comparator<? super K> cmp = comparator;
3847              K f = fence;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines