ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/jsr166e/extra/ReadMostlyVector.java
(Generate patch)

Comparing jsr166/src/jsr166e/extra/ReadMostlyVector.java (file contents):
Revision 1.28 by dl, Fri Oct 12 14:09:35 2012 UTC vs.
Revision 1.29 by jsr166, Fri Oct 12 16:23:28 2012 UTC

# Line 158 | Line 158 | public class ReadMostlyVector<E>
158              else
159                  newCapacity = MAX_ARRAY_SIZE;
160          }
161 <        return array = ((items == null) ?
161 >        return array = ((items == null) ?
162                          new Object[newCapacity] :
163                          Arrays.copyOf(items, newCapacity));
164      }
# Line 427 | Line 427 | public class ReadMostlyVector<E>
427                  n = len;
428              int fence = bound < 0 || bound > n ? n : bound;
429              int i = (origin < 0) ? 0 : origin;
430 <            if (i != fence)
430 >            if (i != fence)
431                  return Arrays.copyOfRange(items, i, fence, Object[].class);
432          }
433          return new Object[0];
# Line 568 | Line 568 | public class ReadMostlyVector<E>
568          final StampedLock lock = this.lock;
569          long stamp = lock.tryOptimisticRead();
570          Object[] items;
571 <        if (index >= 0 && (items = array) != null &&
571 >        if (index >= 0 && (items = array) != null &&
572              index < count && index < items.length) {
573              @SuppressWarnings("unchecked") E e = (E)items[index];
574              if (lock.validate(stamp))
# Line 584 | Line 584 | public class ReadMostlyVector<E>
584          long stamp = lock.readLock();
585          try {
586              Object[] items;
587 <            if ((items = array) != null && index < items.length &&
587 >            if ((items = array) != null && index < items.length &&
588                  index < count && index >= 0)
589                  e = (E)items[index];
590              else
# Line 596 | Line 596 | public class ReadMostlyVector<E>
596              throw new ArrayIndexOutOfBoundsException(index);
597          return (E)e;
598      }
599 <    
599 >
600      public int hashCode() {
601          int h;
602          final StampedLock lock = this.lock;
# Line 608 | Line 608 | public class ReadMostlyVector<E>
608          }
609          return h;
610      }
611 <    
611 >
612      public int indexOf(Object o) {
613          int idx;
614          final StampedLock lock = this.lock;
# Line 743 | Line 743 | public class ReadMostlyVector<E>
743              if (ret != null)
744                  return ret;
745          }
746 <        
746 >
747          throw new ArrayIndexOutOfBoundsException(fromIndex < 0 ? fromIndex : toIndex);
748      }
749  
# Line 867 | Line 867 | public class ReadMostlyVector<E>
867          final StampedLock lock = this.lock;
868          long stamp = lock.readLock();
869          try {
870 <            Object[] items;
870 >            Object[] items;
871              int len, n;
872              if ((items = array) != null && (len = items.length) > 0 &&
873                  (n = count) <= len) {
# Line 921 | Line 921 | public class ReadMostlyVector<E>
921          long stamp = lock.tryOptimisticRead();
922          Object[] items;
923          int i;
924 <        if ((items = array) != null && (i = count - 1) >= 0 &&
924 >        if ((items = array) != null && (i = count - 1) >= 0 &&
925              i < items.length) {
926              @SuppressWarnings("unchecked") E e = (E)items[i];
927              if (lock.validate(stamp))
# Line 974 | Line 974 | public class ReadMostlyVector<E>
974          try {
975              if (index < count)
976                  idx = findLastIndex(array, o, index, 0);
977 <            else
977 >            else
978                  oobe = true;
979          } finally {
980              lock.unlockRead(stamp);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines