a-foundation/src/main/java/com/ajjpj/afoundation/collection/immutable/AList.java
@Override
    public Iterator<T> iterator() {
        return new Iterator<T>() {
            AList<T> pos = AList.this;

            @Override
            public boolean hasNext() {
                return pos.nonEmpty();
            }

            @Override
            public T next() {
                final T result = pos.head();
                pos = pos.tail();
                return result;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
@Override
    public Iterator<T> iterator() {
        return new Iterator<T>() {
            AList<T> pos = AList.this;

            @Override
            public boolean hasNext() {
                return pos.nonEmpty();
            }

            @Override
            public T next() {
                final T result = pos.head();
                pos = pos.tail();
                return result;
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
@ Override public Iterator < T > iterator ( ) { return new Iterator < T > ( ) { AList < T > pos = AList . this ; @ Override public boolean hasNext ( ) { return pos . nonEmpty ( ) ; } @ Override public T next ( ) { final T result = pos . head ( ) ; pos = pos . tail ( ) ; return result ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } ; }
Returns a <code>java.util.Iterator</code> over this AList's elements, allowing ALists to be used with Java's
<code>for(...: list)</code> syntax introduced in version 1.5.
Returns a <code > java . util . Iterator< / code > over this AList s elements allowing ALists to be used with Java s <code > for ( ... : list ) < / code > syntax introduced in version 1 . 5 .