| 11 | package java.util; |
| 12 | |
| 13 | public abstract class AbstractList<T> extends AbstractCollection<T> |
| 14 | implements List<T> |
| 15 | { |
| 16 | protected int modCount; |
| 17 | |
| 18 | public boolean add(T o) { |
| 19 | add(size(), o); |
| 20 | return true; |
| 21 | } |
| 22 | |
| 23 | public boolean addAll(Collection<? extends T> c) { |
| 24 | return addAll(size(), c); |
| 25 | } |
| 26 | |
| 27 | public boolean addAll(int startIndex, Collection<? extends T> c) { |
| 28 | if (c == null) { |
| 29 | throw new NullPointerException("Collection is null"); |
| 30 | } |
| 31 | |
| 32 | int index = startIndex; |
| 33 | boolean changed = false; |
| 34 | |
| 35 | Iterator<? extends T> it = c.iterator(); |
| 36 | while (it.hasNext()) { |
| 37 | add(index++, it.next()); |
| 38 | changed = true; |
| 39 | } |
| 40 | |
| 41 | return changed; |
| 42 | } |
| 43 | |
| 44 | public Iterator<T> iterator() { |
| 45 | return listIterator(); |
| 46 | } |
| 47 | |
| 48 | public ListIterator<T> listIterator() { |
| 49 | return new Collections.ArrayListIterator(this); |
| 50 | } |
| 51 | |
| 52 | public int indexOf(Object o) { |
| 53 | int i = 0; |
| 54 | for (T v: this) { |
| 55 | if (o == null) { |
| 56 | if (v == null) { |
| 57 | return i; |
| 58 | } |
| 59 | } else if (o.equals(v)) { |
| 60 | return i; |
| 61 | } |
| 62 | |
| 63 | ++ i; |
| 64 | } |
| 65 | return -1; |
| 66 | } |
| 67 | } |
nothing calls this directly
no outgoing calls
no test coverage detected