Print this page


Split Close
Expand all
Collapse all
          --- old/src/share/classes/java/util/AbstractList.java
          +++ new/src/share/classes/java/util/AbstractList.java
↓ open down ↓ 167 lines elided ↑ open up ↑
 168  168       * {@inheritDoc}
 169  169       *
 170  170       * <p>This implementation first gets a list iterator (with
 171  171       * {@code listIterator()}).  Then, it iterates over the list until the
 172  172       * specified element is found or the end of the list is reached.
 173  173       *
 174  174       * @throws ClassCastException   {@inheritDoc}
 175  175       * @throws NullPointerException {@inheritDoc}
 176  176       */
 177  177      public int indexOf(Object o) {
 178      -        ListIterator<E> e = listIterator();
      178 +        ListIterator<E> it = listIterator();
 179  179          if (o==null) {
 180      -            while (e.hasNext())
 181      -                if (e.next()==null)
 182      -                    return e.previousIndex();
      180 +            while (it.hasNext())
      181 +                if (it.next()==null)
      182 +                    return it.previousIndex();
 183  183          } else {
 184      -            while (e.hasNext())
 185      -                if (o.equals(e.next()))
 186      -                    return e.previousIndex();
      184 +            while (it.hasNext())
      185 +                if (o.equals(it.next()))
      186 +                    return it.previousIndex();
 187  187          }
 188  188          return -1;
 189  189      }
 190  190  
 191  191      /**
 192  192       * {@inheritDoc}
 193  193       *
 194  194       * <p>This implementation first gets a list iterator that points to the end
 195  195       * of the list (with {@code listIterator(size())}).  Then, it iterates
 196  196       * backwards over the list until the specified element is found, or the
 197  197       * beginning of the list is reached.
 198  198       *
 199  199       * @throws ClassCastException   {@inheritDoc}
 200  200       * @throws NullPointerException {@inheritDoc}
 201  201       */
 202  202      public int lastIndexOf(Object o) {
 203      -        ListIterator<E> e = listIterator(size());
      203 +        ListIterator<E> it = listIterator(size());
 204  204          if (o==null) {
 205      -            while (e.hasPrevious())
 206      -                if (e.previous()==null)
 207      -                    return e.nextIndex();
      205 +            while (it.hasPrevious())
      206 +                if (it.previous()==null)
      207 +                    return it.nextIndex();
 208  208          } else {
 209      -            while (e.hasPrevious())
 210      -                if (o.equals(e.previous()))
 211      -                    return e.nextIndex();
      209 +            while (it.hasPrevious())
      210 +                if (o.equals(it.previous()))
      211 +                    return it.nextIndex();
 212  212          }
 213  213          return -1;
 214  214      }
 215  215  
 216  216  
 217  217      // Bulk Operations
 218  218  
 219  219      /**
 220  220       * Removes all of the elements from this list (optional operation).
 221  221       * The list will be empty after this call returns.
↓ open down ↓ 288 lines elided ↑ open up ↑
 510  510       * @return {@code true} if the specified object is equal to this list
 511  511       */
 512  512      public boolean equals(Object o) {
 513  513          if (o == this)
 514  514              return true;
 515  515          if (!(o instanceof List))
 516  516              return false;
 517  517  
 518  518          ListIterator<E> e1 = listIterator();
 519  519          ListIterator e2 = ((List) o).listIterator();
 520      -        while(e1.hasNext() && e2.hasNext()) {
      520 +        while (e1.hasNext() && e2.hasNext()) {
 521  521              E o1 = e1.next();
 522  522              Object o2 = e2.next();
 523  523              if (!(o1==null ? o2==null : o1.equals(o2)))
 524  524                  return false;
 525  525          }
 526  526          return !(e1.hasNext() || e2.hasNext());
 527  527      }
 528  528  
 529  529      /**
 530  530       * Returns the hash code value for this list.
↓ open down ↓ 251 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX