@Test public void testIterable() { Iterator<String> iter = list.iterator(); assertEquals(FIRST_STRING, iter.next()); assertEquals(MIDDLE_STRING, iter.next()); assertEquals(LAST_STRING, iter.next()); }
public Iterator<T> iterator() { return new Iterator<T>() { final int size = size(); int n = 0; TNode<T> t = first; public boolean hasNext() { return n < size; } public T next() { if (t == first) { t = t.next; } TNode<T> result = t; t = t.next; ++n; return result.data; } public void remove() { throw new UnsupportedOperationException("remove"); } }; }
LinkList implements List<T> { public Iterator<T> iterator() { return new Iterator<T>() { final int size = size(); int n = 0; TNode<T> t = first; public boolean hasNext() { return n < size; } public T next() { if (t == first) { t = t.next; } TNode<T> result = t; t = t.next; ++n; return result.data; } public void remove() { throw new UnsupportedOperationException("remove"); } }; } }
LinkList implements List<T> { public Iterator<T> iterator() { return new Iterator<T>() { final int size = size(); int n = 0; TNode<T> t = first; public boolean hasNext() { return n < size; } public T next() { if (t == first) { t = t.next; } TNode<T> result = t; t = t.next; ++n; return result.data; } public void remove() { throw new UnsupportedOperationException("remove"); } }; } LinkList();  LinkList(Collection<T> c); }
LinkList implements List<T> { public Iterator<T> iterator() { return new Iterator<T>() { final int size = size(); int n = 0; TNode<T> t = first; public boolean hasNext() { return n < size; } public T next() { if (t == first) { t = t.next; } TNode<T> result = t; t = t.next; ++n; return result.data; } public void remove() { throw new UnsupportedOperationException("remove"); } }; } LinkList();  LinkList(Collection<T> c); @Override void clear(); @Override boolean add(T o); @Override void add(int where, T o); @Override boolean addAll(Collection<? extends T> c); @Override boolean addAll(int i, Collection<? extends T> c); @Override boolean contains(Object o); @Override T get(int where); @Override boolean isEmpty(); Iterator<T> iterator(); @Override boolean remove(Object o); @Override T set(int i, T o); @Override int size(); @SuppressWarnings("unchecked") T[] toArray(Object[] data); Object[] toArray(); TNode<T> find(int where); @Override T remove(int i); @Override boolean containsAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<T> listIterator(); @Override ListIterator<T> listIterator(int where); @Override List<T> subList(int sub1, int sub2); @Override boolean removeAll(Collection<?> c); }
LinkList implements List<T> { public Iterator<T> iterator() { return new Iterator<T>() { final int size = size(); int n = 0; TNode<T> t = first; public boolean hasNext() { return n < size; } public T next() { if (t == first) { t = t.next; } TNode<T> result = t; t = t.next; ++n; return result.data; } public void remove() { throw new UnsupportedOperationException("remove"); } }; } LinkList();  LinkList(Collection<T> c); @Override void clear(); @Override boolean add(T o); @Override void add(int where, T o); @Override boolean addAll(Collection<? extends T> c); @Override boolean addAll(int i, Collection<? extends T> c); @Override boolean contains(Object o); @Override T get(int where); @Override boolean isEmpty(); Iterator<T> iterator(); @Override boolean remove(Object o); @Override T set(int i, T o); @Override int size(); @SuppressWarnings("unchecked") T[] toArray(Object[] data); Object[] toArray(); TNode<T> find(int where); @Override T remove(int i); @Override boolean containsAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override int indexOf(Object o); @Override int lastIndexOf(Object o); @Override ListIterator<T> listIterator(); @Override ListIterator<T> listIterator(int where); @Override List<T> subList(int sub1, int sub2); @Override boolean removeAll(Collection<?> c);  }