Note that the iterator cannot be guaranteed to be thread-safe as it is,
generally speaking, impossible to make any hard guarantees in the
presence of unsynchronized concurrent modification.

@returns iterator over values in map
160262
public Iterator<BplusTree.TreeEntry<K, V>> iterator() {
		return new TreeIterator<BplusTree.TreeEntry<K, V>>(this);
	}
821634
@Override
    public Iterator<T> iterator() {
        if (m_items == null) {
            m_items = new TreeMap<String, T>();
        }
        return m_items.values().iterator();
    }
1014291
public Iterator<T> iterator() {

        if (input == null)
            return null;

        if (outputIterator == null)
            outputIterator = new SinkIterator<T>(input.iterator());

        return outputIterator;
    }
1148262
@Override
    public VectorIterator iterator() {
        return new VectorIterator(length) {
            private int i = -1;

            @Override
            public int index() {
                return i;
            }

            @Override
            public double get() {
                return Vector.this.get(i);
            }

            @Override
            public void set(double value) {
                Vector.this.set(i, value);
            }

            @Override
            public boolean hasNext() {
                return i + 1 < length;
            }

            @Override
            public Double next() {
                if(!hasNext()) {
                    throw new NoSuchElementException();
                }
                i++;
                return get();
            }
        };
    }
91954
@Override
	public MutableObjectIterator<E> getIterator() throws InterruptedException {
		synchronized (this.iteratorLock) {
			// wait while both the iterator and the exception are not set
			while (this.iterator == null && this.iteratorException == null) {
				this.iteratorLock.wait();
			}
			
			if (this.iteratorException != null) {
				throw new RuntimeException("Error obtaining the sorted input: " + this.iteratorException.getMessage(),
					this.iteratorException);
			}
			else {
				return this.iterator;
			}
		}
	}
1011771
public static Iterator iterator(final ListModel self) {
        return new Iterator() {
            private int index = 0;

            public boolean hasNext() {
                return index < self.getSize();
            }

            public Object next() {
                return self.getElementAt(index++);
            }

            public void remove() {
                throw new UnsupportedOperationException("LisModel is immutable.");
            }
        };
    }
1063698
@NonNull
    @Override
    public Iterator<Map.Entry<K, V>> iterator() {
        ListIterator<K, V> iterator = new AscendingIterator<>(mStart, mEnd);
        mIterators.put(iterator, false);
        return iterator;
    }
772735
public Iterator getFilterIterator()
    {
        if (m_filter instanceof Map)
            return ((Map)m_filter).values().iterator();
        else if (m_filter != null)
            return new OneFilterIterator();
        else
            return null;    // Okay
    }
397025
public Iterator<Pair<F, S>> getIterator() {
        return new Iterator<Pair<F, S>>() {

            Iterator<F> outerIt;
            Iterator<S> innerIt;
            F curKey;

            {
                outerIt = keySet().iterator();
            }

            private boolean hasInside() {
                if (innerIt == null || !innerIt.hasNext()) {
                    if (!outerIt.hasNext()) {
                        return false;
                    }
                    curKey = outerIt.next();
                    innerIt = getCounter(curKey).keySet().iterator();
                }
                return true;
            }

            public boolean hasNext() {
                return hasInside();
            }

            public Pair<F, S> next() {
                hasInside();
                if (curKey == null)
                    throw new RuntimeException("Outer element can't be null");

                return Pair.makePair(curKey, innerIt.next());
            }

            public void remove() {
                //
            }
        };
    }
1219312
@Override
    public Iterator<T> iterator() {
        List<T> bufferAsList = new ArrayList<T>();
        synchronized (this) {
            synchronized (lock) {
                //First add the items in the expedited buffer
                //Check if we wrap around the end of the array before iterating
                if (expeditedPutIndex > expeditedTakeIndex) {
                    for (int i = expeditedTakeIndex; i <= expeditedPutIndex; i++) {
                        bufferAsList.add(expeditedBuffer[i]);
                    }
                } else {
                    //We wrap around the array. Loop through in two passes(upper and lower)
                    for (int i = expeditedTakeIndex; i < expeditedBuffer.length; i++) {
                        bufferAsList.add(expeditedBuffer[i]);
                    }
                    for (int i = 0; i < expeditedPutIndex; i++) {
                        bufferAsList.add(expeditedBuffer[i]);
                    }
                }
                //Next add the items in the main buffer
                //Check if we wrap around the end of the array before iterating
                if (putIndex > takeIndex) {
                    for (int i = takeIndex; i <= putIndex; i++) {
                        bufferAsList.add(buffer[i]);
                    }
                } else {
                    //We wrap around the array. Loop through in two passes(upper and lower)
                    for (int i = takeIndex; i < buffer.length; i++) {
                        bufferAsList.add(buffer[i]);
                    }
                    for (int i = 0; i < putIndex; i++) {
                        bufferAsList.add(buffer[i]);
                    }
                }
            }
        }
        return bufferAsList.iterator();
    }
154464
@Override
    public IntIterator iterator() {

        return new IntIterator() {

            private final org.roaringbitmap.IntIterator iterator = bitmap.getIntIterator();

            @Override
            public int nextInt() {
                return iterator.next();
            }

            @Override
            public int skip(int k) {
                throw new UnsupportedOperationException("Views do not support skipping in the iterator");
            }

            @Override
            public boolean hasNext() {
                return iterator.hasNext();
            }
        };
    }
1274975
@Override
  public ImmutableCollection<V> values() {
    ImmutableCollection<V> result = values;
    return (result == null) ? values = new ImmutableMapValues<K, V>(this) : result;
  }
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;
        };
    }
456751
private Iterator<ConcurrentServiceReferenceElement<T>> elements() {
        Collection<ConcurrentServiceReferenceElement<T>> set;
        synchronized (elementMap) {
            if (elementSetUnsorted) {
                elementSet = new ConcurrentSkipListSet<ConcurrentServiceReferenceElement<T>>(elementMap.values());
                elementSetUnsorted = false;
            }
            set = elementSet;
        }

        return set.iterator();
    }
1163488
public synchronized Iterator iterator()
   {
		if (tc.isEntryEnabled()) SibTr.entry(this, tc, "iterator");
      Iterator returnValue = idToConvTable.values().iterator();
		if (tc.isEntryEnabled()) SibTr.exit(this, tc, "iterator", returnValue);
   	return returnValue;
   }
1373189
public Iterable<Record> values() {
        return () -> new Iterator<Record>(){
            private final Iterator<Record> it = data.records.values().iterator();

            /** {@inheritDoc} */
            @Override
            public boolean hasNext() {
                return it.hasNext();
            }

            /** {@inheritDoc} */
            @Override
            public Record next() {
                return it.next();
            }

            /** {@inheritDoc} */
            @Override
            public void remove() {
                throw new UnsupportedOperationException("This is a read-only iterator, remove operation is not supported.");
            }
        };
    }
1332830
@Override
    public Iterator<Object> iterator() {
        return new Iterator<Object>() {
            Iterator<Object> iter = list.listIterator();

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

            @Override
            public Object next() {
                return iter.next();
            }

            @Override
            public void remove() {
                iter.remove();
            }
        };
    }