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.13 by jsr166, Fri Aug 5 17:08:04 2011 UTC vs.
Revision 1.20 by jsr166, Sat Dec 31 18:48:47 2011 UTC

# Line 32 | Line 32 | import java.util.*;
32   *
33   * @author Doug Lea
34   */
35 < public class ReadMostlyVector<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable {
35 > public class ReadMostlyVector<E>
36 >        implements List<E>, RandomAccess, Cloneable, java.io.Serializable {
37      private static final long serialVersionUID = 8673264195747942595L;
38  
39      /*
# Line 199 | Line 200 | public class ReadMostlyVector<E> impleme
200          return -1;
201      }
202  
203 <    final void rawAdd(Object e) {
203 >    final void rawAdd(E e) {
204          int n = count;
205          Object[] items = array;
206          if (n >= items.length)
# Line 208 | Line 209 | public class ReadMostlyVector<E> impleme
209          count = n + 1;
210      }
211  
212 <    final void rawAddAt(int index, Object e) {
212 >    final void rawAddAt(int index, E e) {
213          int n = count;
214          Object[] items = array;
215          if (index > n)
# Line 261 | Line 262 | public class ReadMostlyVector<E> impleme
262       * field under lock.
263       */
264      final boolean internalRemoveAll(Collection<?> c, int origin, int bound) {
265 <        SequenceLock lock = this.lock;
265 >        final SequenceLock lock = this.lock;
266          boolean removed = false;
267          lock.lock();
268          try {
# Line 280 | Line 281 | public class ReadMostlyVector<E> impleme
281      }
282  
283      final boolean internalRetainAll(Collection<?> c, int origin, int bound) {
284 <        SequenceLock lock = this.lock;
284 >        final SequenceLock lock = this.lock;
285          boolean removed = false;
286          if (c != this) {
287              lock.lock();
# Line 327 | Line 328 | public class ReadMostlyVector<E> impleme
328      }
329  
330      final boolean internalContainsAll(Collection<?> c, int origin, int bound) {
331 <        SequenceLock lock = this.lock;
331 >        final SequenceLock lock = this.lock;
332          boolean contained;
333          boolean locked = false;
334          try {
# Line 367 | Line 368 | public class ReadMostlyVector<E> impleme
368      }
369  
370      final boolean internalEquals(List<?> list, int origin, int bound) {
371 <        SequenceLock lock = this.lock;
371 >        final SequenceLock lock = this.lock;
372          boolean locked = false;
373          boolean equal;
374          try {
# Line 408 | Line 409 | public class ReadMostlyVector<E> impleme
409      }
410  
411      final int internalHashCode(int origin, int bound) {
412 <        SequenceLock lock = this.lock;
412 >        final SequenceLock lock = this.lock;
413          int hash;
414          boolean locked = false;
415          try {
# Line 440 | Line 441 | public class ReadMostlyVector<E> impleme
441      }
442  
443      final String internalToString(int origin, int bound) {
444 <        SequenceLock lock = this.lock;
444 >        final SequenceLock lock = this.lock;
445          String ret;
446          boolean locked = false;
447          try {
# Line 487 | Line 488 | public class ReadMostlyVector<E> impleme
488  
489      final Object[] internalToArray(int origin, int bound) {
490          Object[] result;
491 <        SequenceLock lock = this.lock;
491 >        final SequenceLock lock = this.lock;
492          boolean locked = false;
493          try {
494              for (;;) {
# Line 514 | Line 515 | public class ReadMostlyVector<E> impleme
515          return result;
516      }
517  
518 +    @SuppressWarnings("unchecked")
519      final <T> T[] internalToArray(T[] a, int origin, int bound) {
520          int alen = a.length;
521          T[] result;
522 <        SequenceLock lock = this.lock;
522 >        final SequenceLock lock = this.lock;
523          boolean locked = false;
524          try {
525              for (;;) {
# Line 556 | Line 558 | public class ReadMostlyVector<E> impleme
558      // public List methods
559  
560      public boolean add(E e) {
561 <        SequenceLock lock = this.lock;
561 >        final SequenceLock lock = this.lock;
562          lock.lock();
563          try {
564              rawAdd(e);
# Line 567 | Line 569 | public class ReadMostlyVector<E> impleme
569      }
570  
571      public void add(int index, E element) {
572 <        SequenceLock lock = this.lock;
572 >        final SequenceLock lock = this.lock;
573          lock.lock();
574          try {
575              rawAddAt(index, element);
# Line 581 | Line 583 | public class ReadMostlyVector<E> impleme
583          int len = elements.length;
584          if (len == 0)
585              return false;
586 <        SequenceLock lock = this.lock;
586 >        final SequenceLock lock = this.lock;
587          lock.lock();
588          try {
589              Object[] items = array;
# Line 598 | Line 600 | public class ReadMostlyVector<E> impleme
600      }
601  
602      public boolean addAll(int index, Collection<? extends E> c) {
603 <        SequenceLock lock = this.lock;
603 >        final SequenceLock lock = this.lock;
604          boolean ret;
605          Object[] elements = c.toArray();
606          lock.lock();
# Line 611 | Line 613 | public class ReadMostlyVector<E> impleme
613      }
614  
615      public void clear() {
616 <        SequenceLock lock = this.lock;
616 >        final SequenceLock lock = this.lock;
617          lock.lock();
618          try {
619              int n = count;
# Line 641 | Line 643 | public class ReadMostlyVector<E> impleme
643      }
644  
645      public E get(int index) {
646 <        SequenceLock lock = this.lock;
646 >        final SequenceLock lock = this.lock;
647          for (;;) {
648              long seq = lock.awaitAvailability();
649              int n = count;
650              Object[] items = array;
651 <            if (n > items.length)
652 <                continue;
651 <            Object e; boolean ex;
652 <            if (index < 0 || index >= n) {
653 <                e = null;
654 <                ex = true;
655 <            }
656 <            else {
657 <                e = items[index];
658 <                ex = false;
659 <            }
651 >            @SuppressWarnings("unchecked")
652 >            E e = (index < items.length) ? (E) items[index] : null;
653              if (lock.getSequence() == seq) {
654 <                if (ex)
654 >                if (index >= n)
655                      throw new ArrayIndexOutOfBoundsException(index);
656 <                else
664 <                    return (E)e;
656 >                return e;
657              }
658          }
659      }
# Line 671 | Line 663 | public class ReadMostlyVector<E> impleme
663      }
664  
665      public int indexOf(Object o) {
666 <        SequenceLock lock = this.lock;
675 <        for (;;) {
676 <            long seq = lock.awaitAvailability();
677 <            Object[] items = array;
678 <            int n = count;
679 <            if (n <= items.length) {
680 <                for (int i = 0; i < n; ++i) {
681 <                    Object e = items[i];
682 <                    if (lock.getSequence() != seq) {
683 <                        lock.lock();
684 <                        try {
685 <                            return rawIndexOf(o, 0, count);
686 <                        } finally {
687 <                            lock.unlock();
688 <                        }
689 <                    }
690 <                    else if ((o == null) ? e == null : o.equals(e))
691 <                        return i;
692 <                }
693 <                return -1;
694 <            }
695 <        }
666 >        return indexOf(o, 0);
667      }
668  
669      public boolean isEmpty() {
# Line 704 | Line 675 | public class ReadMostlyVector<E> impleme
675      }
676  
677      public int lastIndexOf(Object o) {
678 <        SequenceLock lock = this.lock;
678 >        final SequenceLock lock = this.lock;
679          for (;;) {
680              long seq = lock.awaitAvailability();
681              Object[] items = array;
# Line 715 | Line 686 | public class ReadMostlyVector<E> impleme
686                      if (lock.getSequence() != seq) {
687                          lock.lock();
688                          try {
689 <                            return rawLastIndexOf(o, 0, count);
689 >                            return rawLastIndexOf(o, count, 0);
690                          } finally {
691                              lock.unlock();
692                          }
# Line 737 | Line 708 | public class ReadMostlyVector<E> impleme
708      }
709  
710      public E remove(int index) {
711 <        SequenceLock lock = this.lock;
741 <        Object oldValue;
711 >        final SequenceLock lock = this.lock;
712          lock.lock();
713          try {
714              if (index < 0 || index >= count)
715                  throw new ArrayIndexOutOfBoundsException(index);
716 <            oldValue = array[index];
716 >            @SuppressWarnings("unchecked")
717 >            E oldValue = (E) array[index];
718              rawRemoveAt(index);
719 +            return oldValue;
720          } finally {
721              lock.unlock();
722          }
751        return (E)oldValue;
723      }
724  
725      public boolean remove(Object o) {
726 <        SequenceLock lock = this.lock;
756 <        boolean removed;
726 >        final SequenceLock lock = this.lock;
727          lock.lock();
728          try {
729 <            removed = rawRemoveAt(rawIndexOf(o, 0, count));
729 >            return rawRemoveAt(rawIndexOf(o, 0, count));
730          } finally {
731              lock.unlock();
732          }
763        return removed;
733      }
734  
735      public boolean removeAll(Collection<?> c) {
# Line 772 | Line 741 | public class ReadMostlyVector<E> impleme
741      }
742  
743      public E set(int index, E element) {
744 <        Object oldValue;
776 <        SequenceLock lock = this.lock;
744 >        final SequenceLock lock = this.lock;
745          lock.lock();
746          try {
747              Object[] items = array;
748              if (index < 0 || index >= count)
749                  throw new ArrayIndexOutOfBoundsException(index);
750 <            oldValue = items[index];
750 >            @SuppressWarnings("unchecked")
751 >            E oldValue = (E) items[index];
752              items[index] = element;
753 +            return oldValue;
754          } finally {
755              lock.unlock();
756          }
787        return (E)oldValue;
757      }
758  
759      public int size() {
# Line 820 | Line 789 | public class ReadMostlyVector<E> impleme
789       * @return {@code true} if the element was added
790       */
791      public boolean addIfAbsent(E e) {
792 <        boolean added;
824 <        SequenceLock lock = this.lock;
792 >        final SequenceLock lock = this.lock;
793          lock.lock();
794          try {
795              if (rawIndexOf(e, 0, count) < 0) {
796                  rawAdd(e);
797 <                added = true;
797 >                return true;
798              }
799              else
800 <                added = false;
800 >                return false;
801          } finally {
802              lock.unlock();
803          }
836        return added;
804      }
805  
806      /**
# Line 855 | Line 822 | public class ReadMostlyVector<E> impleme
822              lock.lock();
823              try {
824                  for (int i = 0; i < clen; ++i) {
825 <                    Object e = cs[i];
825 >                    @SuppressWarnings("unchecked")
826 >                    E e = (E) cs[i];
827                      if (rawIndexOf(e, 0, count) < 0) {
828                          rawAdd(e);
829                          ++added;
# Line 881 | Line 849 | public class ReadMostlyVector<E> impleme
849      }
850  
851      static final class SnapshotIterator<E> implements Iterator<E> {
852 <        final Object[] items;
853 <        int cursor;
852 >        private final Object[] items;
853 >        private int cursor;
854          SnapshotIterator(ReadMostlyVector<E> v) { items = v.toArray(); }
855          public boolean hasNext() { return cursor < items.length; }
856 +        @SuppressWarnings("unchecked")
857          public E next() {
858              if (cursor < items.length)
859                  return (E) items[cursor++];
# Line 897 | Line 866 | public class ReadMostlyVector<E> impleme
866  
867      /** See {@link Vector#firstElement} */
868      public E firstElement() {
869 <        SequenceLock lock = this.lock;
869 >        final SequenceLock lock = this.lock;
870          for (;;) {
871              long seq = lock.awaitAvailability();
872              Object[] items = array;
904            int len = items.length;
873              int n = count;
874 <            if (n > len)
875 <                continue;
908 <            Object e; boolean ex;
909 <            if (n > 0) {
910 <                e = items[0];
911 <                ex = false;
912 <            }
913 <            else {
914 <                e = null;
915 <                ex = true;
916 <            }
874 >            @SuppressWarnings("unchecked")
875 >            E e = (items.length > 0) ? (E) items[0] : null;
876              if (lock.getSequence() == seq) {
877 <                if (ex)
877 >                if (n <= 0)
878                      throw new NoSuchElementException();
879 <                else
921 <                    return (E)e;
879 >                return e;
880              }
881          }
882      }
883  
884      /** See {@link Vector#lastElement} */
885      public E lastElement() {
886 <        SequenceLock lock = this.lock;
886 >        final SequenceLock lock = this.lock;
887          for (;;) {
888              long seq = lock.awaitAvailability();
889              Object[] items = array;
932            int len = items.length;
890              int n = count;
891 <            if (n > len)
892 <                continue;
936 <            Object e; boolean ex;
937 <            if (n > 0) {
938 <                e = items[n - 1];
939 <                ex = false;
940 <            }
941 <            else {
942 <                e = null;
943 <                ex = true;
944 <            }
891 >            @SuppressWarnings("unchecked")
892 >            E e = (n > 0 && items.length >= n) ? (E) items[n - 1] : null;
893              if (lock.getSequence() == seq) {
894 <                if (ex)
894 >                if (n <= 0)
895                      throw new NoSuchElementException();
896 <                else
949 <                    return (E)e;
896 >                return e;
897              }
898          }
899      }
900  
901      /** See {@link Vector#indexOf(Object, int)} */
902      public int indexOf(Object o, int index) {
903 <        SequenceLock lock = this.lock;
903 >        final SequenceLock lock = this.lock;
904          int idx = 0;
905          boolean ex = false;
906          long seq = lock.awaitAvailability();
# Line 972 | Line 919 | public class ReadMostlyVector<E> impleme
919                  if (index < 0)
920                      ex = true;
921                  else
922 <                    idx = rawIndexOf(o, 0, count);
922 >                    idx = rawIndexOf(o, index, count);
923              } finally {
924                  lock.unlock();
925              }
# Line 984 | Line 931 | public class ReadMostlyVector<E> impleme
931  
932      /** See {@link Vector#lastIndexOf(Object, int)} */
933      public int lastIndexOf(Object o, int index) {
934 <        SequenceLock lock = this.lock;
934 >        final SequenceLock lock = this.lock;
935          int idx = 0;
936          boolean ex = false;
937          long seq = lock.awaitAvailability();
# Line 1017 | Line 964 | public class ReadMostlyVector<E> impleme
964      public void setSize(int newSize) {
965          if (newSize < 0)
966              throw new ArrayIndexOutOfBoundsException(newSize);
967 <        SequenceLock lock = this.lock;
967 >        final SequenceLock lock = this.lock;
968          lock.lock();
969          try {
970              int n = count;
# Line 1036 | Line 983 | public class ReadMostlyVector<E> impleme
983  
984      /** See {@link Vector#copyInto} */
985      public void copyInto(Object[] anArray) {
986 <        SequenceLock lock = this.lock;
986 >        final SequenceLock lock = this.lock;
987          lock.lock();
988          try {
989              System.arraycopy(array, 0, anArray, 0, count);
# Line 1047 | Line 994 | public class ReadMostlyVector<E> impleme
994  
995      /** See {@link Vector#trimToSize} */
996      public void trimToSize() {
997 <        SequenceLock lock = this.lock;
997 >        final SequenceLock lock = this.lock;
998          lock.lock();
999          try {
1000              Object[] items = array;
# Line 1062 | Line 1009 | public class ReadMostlyVector<E> impleme
1009      /** See {@link Vector#ensureCapacity} */
1010      public void ensureCapacity(int minCapacity) {
1011          if (minCapacity > 0) {
1012 <            SequenceLock lock = this.lock;
1012 >            final SequenceLock lock = this.lock;
1013              lock.lock();
1014              try {
1015                  if (minCapacity - array.length > 0)
# Line 1121 | Line 1068 | public class ReadMostlyVector<E> impleme
1068      // other methods
1069  
1070      public ReadMostlyVector<E> clone() {
1071 <        SequenceLock lock = this.lock;
1071 >        final SequenceLock lock = this.lock;
1072          Object[] a = null;
1073          boolean retry = false;
1074          long seq = lock.awaitAvailability();
# Line 1145 | Line 1092 | public class ReadMostlyVector<E> impleme
1092  
1093      private void writeObject(java.io.ObjectOutputStream s)
1094              throws java.io.IOException {
1095 <        SequenceLock lock = this.lock;
1095 >        final SequenceLock lock = this.lock;
1096          lock.lock();
1097          try {
1098              s.defaultWriteObject();
# Line 1154 | Line 1101 | public class ReadMostlyVector<E> impleme
1101          }
1102      }
1103  
1104 <    static final class Itr<E> implements ListIterator<E>, Enumeration<E>  {
1104 >    static final class Itr<E> implements ListIterator<E>, Enumeration<E> {
1105          final ReadMostlyVector<E> list;
1106          final SequenceLock lock;
1107          Object[] items;
1108 <        Object next, prev;
1108 >        E next, prev;
1109          long seq;
1110          int cursor;
1111          int fence;
# Line 1184 | Line 1131 | public class ReadMostlyVector<E> impleme
1131                       lock.getSequence() != seq);
1132          }
1133  
1134 +        @SuppressWarnings("unchecked")
1135          public boolean hasNext() {
1136              boolean valid;
1137              int i = cursor;
# Line 1192 | Line 1140 | public class ReadMostlyVector<E> impleme
1140                      valid = false;
1141                      break;
1142                  }
1143 <                next = items[i];
1143 >                next = (E) items[i];
1144                  if (lock.getSequence() == seq) {
1145                      valid = true;
1146                      break;
# Line 1202 | Line 1150 | public class ReadMostlyVector<E> impleme
1150              return validNext = valid;
1151          }
1152  
1153 +        @SuppressWarnings("unchecked")
1154          public boolean hasPrevious() {
1155              boolean valid;
1156              int i = cursor - 1;
# Line 1210 | Line 1159 | public class ReadMostlyVector<E> impleme
1159                      valid = false;
1160                      break;
1161                  }
1162 <                prev = items[i];
1162 >                prev = (E) items[i];
1163                  if (lock.getSequence() == seq) {
1164                      valid = true;
1165                      break;
# Line 1224 | Line 1173 | public class ReadMostlyVector<E> impleme
1173              if (validNext || hasNext()) {
1174                  validNext = false;
1175                  lastRet = cursor++;
1176 <                return (E) next;
1176 >                return next;
1177              }
1178              throw new NoSuchElementException();
1179          }
# Line 1233 | Line 1182 | public class ReadMostlyVector<E> impleme
1182              if (validPrev || hasPrevious()) {
1183                  validPrev = false;
1184                  lastRet = cursor--;
1185 <                return (E) prev;
1185 >                return prev;
1186              }
1187              throw new NoSuchElementException();
1188          }
# Line 1290 | Line 1239 | public class ReadMostlyVector<E> impleme
1239          public int previousIndex() { return cursor - 1; }
1240      }
1241  
1242 <    static final class ReadMostlyVectorSublist<E> implements List<E>, RandomAccess, java.io.Serializable {
1242 >    static final class ReadMostlyVectorSublist<E>
1243 >            implements List<E>, RandomAccess, java.io.Serializable {
1244 >        static final long serialVersionUID = 3041673470172026059L;
1245 >
1246          final ReadMostlyVector<E> list;
1247          final int offset;
1248          volatile int size;
1249  
1250 <        ReadMostlyVectorSublist(ReadMostlyVector<E> list, int offset, int size) {
1250 >        ReadMostlyVectorSublist(ReadMostlyVector<E> list,
1251 >                                int offset, int size) {
1252              this.list = list;
1253              this.offset = offset;
1254              this.size = size;
# Line 1307 | Line 1260 | public class ReadMostlyVector<E> impleme
1260          }
1261  
1262          public boolean add(E element) {
1263 <            SequenceLock lock = list.lock;
1263 >            final SequenceLock lock = list.lock;
1264              lock.lock();
1265              try {
1266                  int c = size;
# Line 1320 | Line 1273 | public class ReadMostlyVector<E> impleme
1273          }
1274  
1275          public void add(int index, E element) {
1276 <            SequenceLock lock = list.lock;
1276 >            final SequenceLock lock = list.lock;
1277              lock.lock();
1278              try {
1279                  if (index < 0 || index > size)
# Line 1334 | Line 1287 | public class ReadMostlyVector<E> impleme
1287  
1288          public boolean addAll(Collection<? extends E> c) {
1289              Object[] elements = c.toArray();
1290 <            int added;
1338 <            SequenceLock lock = list.lock;
1290 >            final SequenceLock lock = list.lock;
1291              lock.lock();
1292              try {
1293                  int s = size;
1294                  int pc = list.count;
1295                  list.rawAddAllAt(offset + s, elements);
1296 <                added = list.count - pc;
1296 >                int added = list.count - pc;
1297                  size = s + added;
1298 +                return added != 0;
1299              } finally {
1300                  lock.unlock();
1301              }
1349            return added != 0;
1302          }
1303  
1304          public boolean addAll(int index, Collection<? extends E> c) {
1305              Object[] elements = c.toArray();
1306 <            int added;
1355 <            SequenceLock lock = list.lock;
1306 >            final SequenceLock lock = list.lock;
1307              lock.lock();
1308              try {
1309                  int s = size;
# Line 1360 | Line 1311 | public class ReadMostlyVector<E> impleme
1311                      throw new ArrayIndexOutOfBoundsException(index);
1312                  int pc = list.count;
1313                  list.rawAddAllAt(index + offset, elements);
1314 <                added = list.count - pc;
1314 >                int added = list.count - pc;
1315                  size = s + added;
1316 +                return added != 0;
1317              } finally {
1318                  lock.unlock();
1319              }
1368            return added != 0;
1320          }
1321  
1322          public void clear() {
1323 <            SequenceLock lock = list.lock;
1323 >            final SequenceLock lock = list.lock;
1324              lock.lock();
1325              try {
1326                  list.internalClear(offset, offset + size);
# Line 1406 | Line 1357 | public class ReadMostlyVector<E> impleme
1357          }
1358  
1359          public int indexOf(Object o) {
1360 <            SequenceLock lock = list.lock;
1360 >            final SequenceLock lock = list.lock;
1361              long seq = lock.awaitAvailability();
1362              Object[] items = list.array;
1363              int c = list.count;
# Line 1434 | Line 1385 | public class ReadMostlyVector<E> impleme
1385          }
1386  
1387          public int lastIndexOf(Object o) {
1388 <            SequenceLock lock = list.lock;
1388 >            final SequenceLock lock = list.lock;
1389              long seq = lock.awaitAvailability();
1390              Object[] items = list.array;
1391              int c = list.count;
# Line 1462 | Line 1413 | public class ReadMostlyVector<E> impleme
1413          }
1414  
1415          public E remove(int index) {
1416 <            Object result;
1466 <            SequenceLock lock = list.lock;
1416 >            final SequenceLock lock = list.lock;
1417              lock.lock();
1418              try {
1419                  Object[] items = list.array;
1420                  int i = index + offset;
1421                  if (index < 0 || index >= size || i >= items.length)
1422                      throw new ArrayIndexOutOfBoundsException(index);
1423 <                result = items[i];
1423 >                @SuppressWarnings("unchecked")
1424 >                E result = (E) items[i];
1425                  list.rawRemoveAt(i);
1426                  size--;
1427 +                return result;
1428              } finally {
1429                  lock.unlock();
1430              }
1479            return (E)result;
1431          }
1432  
1433          public boolean remove(Object o) {
1434 <            boolean removed = false;
1484 <            SequenceLock lock = list.lock;
1434 >            final SequenceLock lock = list.lock;
1435              lock.lock();
1436              try {
1437                  if (list.rawRemoveAt(list.rawIndexOf(o, offset,
1438                                                       offset + size))) {
1489                    removed = true;
1439                      --size;
1440 +                    return true;
1441                  }
1442 +                else
1443 +                    return false;
1444              } finally {
1445                  lock.unlock();
1446              }
1495            return removed;
1447          }
1448  
1449          public boolean removeAll(Collection<?> c) {
# Line 1540 | Line 1491 | public class ReadMostlyVector<E> impleme
1491          final ReadMostlyVector<E> list;
1492          final SequenceLock lock;
1493          Object[] items;
1494 <        Object next, prev;
1494 >        E next, prev;
1495          long seq;
1496          int cursor;
1497          int fence;
# Line 1571 | Line 1522 | public class ReadMostlyVector<E> impleme
1522              } while (lock.getSequence() != seq);
1523          }
1524  
1525 +        @SuppressWarnings("unchecked")
1526          public boolean hasNext() {
1527              boolean valid;
1528              int i = cursor;
# Line 1579 | Line 1531 | public class ReadMostlyVector<E> impleme
1531                      valid = false;
1532                      break;
1533                  }
1534 <                next = items[i];
1534 >                next = (E) items[i];
1535                  if (lock.getSequence() == seq) {
1536                      valid = true;
1537                      break;
# Line 1589 | Line 1541 | public class ReadMostlyVector<E> impleme
1541              return validNext = valid;
1542          }
1543  
1544 +        @SuppressWarnings("unchecked")
1545          public boolean hasPrevious() {
1546              boolean valid;
1547              int i = cursor - 1;
# Line 1597 | Line 1550 | public class ReadMostlyVector<E> impleme
1550                      valid = false;
1551                      break;
1552                  }
1553 <                prev = items[i];
1553 >                prev = (E) items[i];
1554                  if (lock.getSequence() == seq) {
1555                      valid = true;
1556                      break;
# Line 1611 | Line 1564 | public class ReadMostlyVector<E> impleme
1564              if (validNext || hasNext()) {
1565                  validNext = false;
1566                  lastRet = cursor++;
1567 <                return (E) next;
1567 >                return next;
1568              }
1569              throw new NoSuchElementException();
1570          }
# Line 1620 | Line 1573 | public class ReadMostlyVector<E> impleme
1573              if (validPrev || hasPrevious()) {
1574                  validPrev = false;
1575                  lastRet = cursor--;
1576 <                return (E) prev;
1576 >                return prev;
1577              }
1578              throw new NoSuchElementException();
1579          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines