Implentation for Iterable interface.
Please note: each call for iterator() resets underlying SentenceIterator to the beginning;

@return
486782
@Override
    public Iterator<String> iterator() {
        this.reset();
        Iterator<String> ret = new Iterator<String>() {
            @Override
            public boolean hasNext() {
                return BasicLineIterator.this.hasNext();
            }

            @Override
            public String next() {
                return BasicLineIterator.this.nextSentence();
            }

            @Override
            public void remove() {
                throw new UnsupportedOperationException();
            }
        };

        return ret;
    }
1080323
public Iterator<E> iterator ()
    {
        // the crazy sanity checks
        if (_size < 0 || _size > _entries.length || (_size > 0 && _entries[_size-1] == null)) {
            log.warning("DSet in a bad way", "size", _size, "entries", _entries, new Exception());
        }

        return new Iterator<E>() {
            public boolean hasNext () {
                checkComodification();
                return (_index < _size);
            }
            public E next () {
                checkComodification();
                return _entries[_index++];
            }
            public void remove () {
                throw new UnsupportedOperationException();
            }
            protected void checkComodification () {
                if (_modCount != _expectedModCount) {
                    throw new ConcurrentModificationException();
                }
                if (_ssize != _size) {
                    log.warning("Size changed during iteration", "ssize", _ssize, "nsize", _size,
                                "entries", _entries, new Exception());
                }
            }
            protected int _index = 0;
            protected int _ssize = _size;
            protected int _expectedModCount = _modCount;
        };
    }
411376
@Nonnull
    public Iterator<S> bfsIterator() {
        Set<S> visited = new HashSet<>();
        final Deque<S> bfsQueue = new ArrayDeque<>();
        bfsQueue.add(root);
        visited.add(root);

        return new AbstractIterator<S>() {

            @Override
            protected S computeNext() {
                S next = bfsQueue.poll();
                if (next == null) {
                    return endOfData();
                }
                for (int i = 0; i < alphabetSize; i++) {
                    S child = next.getSuccessor(i);
                    if (child != null && visited.add(child)) {
                        bfsQueue.offer(child);
                    }
                }
                return next;
            }
        };
    }
433206
@Override
    public ICodeBaseIterator iterator() throws InterruptedException {
        return new ICodeBaseIterator() {
            boolean done = false;

            /*
             * (non-Javadoc)
             *
             * @see edu.umd.cs.findbugs.classfile.ICodeBaseIterator#hasNext()
             */
            @Override
            public boolean hasNext() throws InterruptedException {
                return !done;
            }

            /*
             * (non-Javadoc)
             *
             * @see edu.umd.cs.findbugs.classfile.ICodeBaseIterator#next()
             */
            @Override
            public ICodeBaseEntry next() throws InterruptedException {
                if (done) {
                    throw new NoSuchElementException();
                }
                done = true;
                return new SingleFileCodeBaseEntry(SingleFileCodeBase.this);
            }
        };
    }
626951
public SIMPIterator getTopicNameIterator()
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.entry(tc, "getTopicNameIterator");
    //if the stream is flushed then we have not subscribed
    //to any topics, so we return an empty list
    List topicList = null;
    if(_anycastInputHandler.getAIStream()!=null)
    {
      String[] topics =
            _anycastInputHandler.getRCD().getConsumerDispatcherState().getTopics();
       topicList = Arrays.asList(topics);
    }
    else
    {
      //we are flushed, so we are not currently subscribing for any
      //topics
      topicList = new LinkedList(); //create an empty collection
    }
    
    BasicSIMPIterator iterator = new BasicSIMPIterator(topicList.iterator());
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
      SibTr.exit(tc, "getTopicNameIterator", iterator);
    return iterator;                                   
  }
188869
public Iterator<E> iterator() {

        return new Iterator<E>() {

            public boolean hasNext() {
                return enumeration.hasMoreElements();
            }

            public E next() {
                return enumeration.nextElement();
            }

            public void remove() {
                throw new UnsupportedOperationException("IterableEnumeration does not support remove");
            }
        };
    }
240118
public Iterator<Symbol> iterator() {
        return scope.getSymbols(t -> !unwanted(t), NON_RECURSIVE).iterator();
    }
1109101
public Iterator<E> iterator() {
        final Iterator<? extends E> itr = core.iterator();
        return new Iterator<E>() {
            private E last;
            public boolean hasNext() {
                return itr.hasNext();
            }

            public E next() {
                return last=itr.next();
            }

            public void remove() {
                CopyOnWriteList.this.remove(last);
            }
        };
    }
1298973
@Override
  public Iterator<Reader> iterator() {
    Collection<Object> newCollection = new ArrayList<Object>();
    for (Object o : c) {
      if (o instanceof Reader) {
        String name = o.toString()+".tmp";
        File tmpFile;
        try {
          tmpFile = File.createTempFile(name,"");
        } catch (Exception e) {
          throw new RuntimeException(e.getMessage());
        }
        tmpFile.deleteOnExit();
        StringUtils.printToFile(tmpFile, IOUtils.slurpReader((Reader)o),
                                false, false, enc);
        newCollection.add(tmpFile);
      } else {
        newCollection.add(o);
      }
    }
    c = newCollection;
    return new ReaderIterator();
  }
951584
@Override
    public Iterator<T> iterator() {
        
        /*
         * We make a copy of the allResults list to iterate over in order to
         * avoid ConcurrentModificationExceptions caused by other methods
         * loading more results into the list while someone iterates over it.
         * This is a more severe problem than it might seem, because even
         * innocuous-seeming operations such as contains() can modify the
         * underlying result set.
         */
        final List<T> allResultsCopy = new ArrayList<T>();
        allResultsCopy.addAll(allResults);        
        final Iterator<T> iter = allResultsCopy.iterator();
        
        return new Iterator<T>() {
    
            Iterator<T> iterator = iter;
            int pos = 0;
            
            @Override
            public boolean hasNext() {
                return iterator.hasNext() || nextResultsAvailable();
            }
    
            @Override
            public T next() {
                if ( !iterator.hasNext() ) {
                    /*
                     * Our private copy of the result list may be out of date
                     * with the full one. If it is, we just need to update our
                     * private copy to get more results. If it's not, we need to
                     * fetch more results from the service.
                     */
                    if ( allResults.size() == allResultsCopy.size() ) {
                        if ( !nextResultsAvailable() ) {
                            throw new NoSuchElementException();
                        }
                        moveNextResults();
                    } 
                    
                    if ( allResults.size() > allResultsCopy.size() )
                        allResultsCopy.addAll(allResults.subList(allResultsCopy.size(), allResults.size()));
                    
                    iterator = allResultsCopy.listIterator(pos);
                }
                
                pos++;
                return iterator.next();
            }
            
            @Override
            public void remove() {
                throw new UnsupportedOperationException(UNMODIFIABLE_MESSAGE);
            }            
        };
    }
219334
public IntIterator getIntIterator() {
		return new IntIterator() {
			int wordindex;
			int i = 0;
			IntArray buf;
			int currentword;

			public IntIterator init(IntArray b) {
				this.buf = b;
				this.wordindex = this.buf.get(this.i);
				this.currentword = this.buf.get(this.i + 1);
				return this;
			}

			@Override
			public boolean hasNext() {
				return this.currentword != 0;
			}

			@Override
			public int next() {
				final int offset = Integer
						.numberOfTrailingZeros(this.currentword);
				this.currentword ^= 1 << offset;
				final int answer = this.wordindex * WORDSIZE + offset;
				if (this.currentword == 0) {
					this.i += 2;
					if (this.i < this.buf.size()) {
						this.currentword = this.buf.get(this.i + 1);
						this.wordindex += this.buf.get(this.i) + 1;
					}
				}
				return answer;
			}

		}.init(this.buffer);
	}
403956
public Iterator<SourceUnit> iterator() {
        return new Iterator<SourceUnit>() {
            Iterator<String> nameIterator = names.iterator();

            public boolean hasNext() {
                return nameIterator.hasNext();
            }

            public SourceUnit next() {
                String name = nameIterator.next();
                return sources.get(name);
            }

            public void remove() {
                throw new UnsupportedOperationException();
            }
        };
    }
688658
public static <T> Predicate<T> iterablePresent() {
        return t -> t instanceof Iterable ? ((Iterable) t).iterator()
                                                          .hasNext()
                : false;
    }
788785
public Iterator iterator()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "iterator");

        Iterator iterator = subList(null, null).iterator();

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       "iterator",
                       new Object[] { iterator });
        return iterator;
    }
1204585
public Iterable<V> values() {
    return new Iterable<V>() {
      @Override
      public Iterator<V> iterator() {
        return new Iterator<V>() {
          final Iterator<List<V>> valuesIterator = map.values().iterator();
          Iterator<V> current;

          {
            if (valuesIterator.hasNext())
              current = valuesIterator.next().iterator();
          }

          @Override
          public boolean hasNext() {
            return current != null && current.hasNext();
          }

          @Override
          public V next() {
            V value = current.next();
            while (!current.hasNext() && valuesIterator.hasNext())
              current = valuesIterator.next().iterator();
            return value;
          }

          @Override
          public void remove() {
            throw new UnsupportedOperationException();
          }
        };
      }
    };
  }
911090
@SuppressWarnings("unchecked")
  public static Iterator<Object> iterator(Object iterable) {
    Assert.state(isIterable(iterable.getClass()));
    return iterable.getClass().isArray() ? new ArrayIterator(iterable)
        : ((Iterable<Object>) iterable).iterator();
  }
240831
public static <E> Iterable<E> asIterable(final Iterator<E> iter) {
		return IterUtil.asIterable(iter);
	}