Casts {@link Iterator} by taking advantage of its covariant-ness.
175283
@SuppressWarnings({"unchecked"})
    public static <T> Iterator<T> cast(Iterator<? extends T> itr) {
        return (Iterator)itr;
    }
716240
public static <T> Stream<T> toStream( Iterator<T> iterator)
    {
    Iterable<T> iterable = () -> iterator;
    return toStream( iterable);
    }
900998
public Iterator<V> values()
  {
    ValueIterator<K,V> iter = new ValueIterator<K,V>(this);
    iter.init(this);
    return iter;
  }
240858
public static <T> Iterator<T> merge(Iterator<T>... iterators)
    {
        return merge(null, iterators);
    }
21664
private Iterable<YamlNode> cast(Iterable<Object> nodes) {
        return () -> new UnmodifiableIterator<YamlNode>() {
            private final Iterator<Object> iter = nodes.iterator();

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

            @Override
            public YamlNode next() {
                return (YamlNode) iter.next();
            }
        };
    }
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();
  }
670642
public Iterator<T> iterator() {
        List<Iterator<T>> iters = new ArrayList<Iterator<T>>(sets.size());
        for (Set<T> s : sets)
            iters.add(s.iterator());
        return new CombinedIterator<T>(iters);
    }
386777
private static Iterator<int[]> initializeValueIterator(VariableNumMap vars) {
		int[] dimensionSizes = new int[vars.size()];
		
		List<DiscreteVariable> discreteVars = vars.getDiscreteVariables();
		for (int i = 0; i < discreteVars.size(); i++) {
		  dimensionSizes[i] = discreteVars.get(i).numValues();
		}
		return new IntegerArrayIterator(dimensionSizes, new int[0]);
	}
768028
protected final void setResultIterator(MutableObjectIterator<E> iterator) {
		synchronized (this.iteratorLock) {
			// set the result iterator only, if no exception has occurred
			if (this.iteratorException == null) {
				this.iterator = iterator;
				this.iteratorLock.notifyAll();
			}
		}
	}
977031
public static Iterator makeIterator( Object obj, IType typeHint )
  {
    if( obj == null )
    {
      return null;
    }

    if( typeHint.isArray() &&
        (obj.getClass().isArray() || TypeSystem.getFromObject( obj ).isArray()) )
    {
      return new ArrayIterator( obj, typeHint );
    }

    if( obj instanceof Iterable )
    {
      return ((Iterable)obj).iterator();
    }

    if( obj instanceof Iterator )
    {
      return(Iterator)obj;
    }

    // Treat a string as a list of characters
    if( obj instanceof String )
    {
      return new StringIterator( (String)obj );
    }

    if( obj instanceof Number )
    {
      return new NumberIterator( (Number)obj );
    }

    // Oh well. Convert to a List of length one and iterate that single element.
    return Collections.nCopies( 1, obj ).iterator();
  }
802244
public Iterator<Example> iterator()
    {
        return new Iterator<Example>()
        {
            private int index = 0;

            public boolean hasNext()
            {
                return at( index ) != null;
            }

            public Example next()
            {
                return at( index++ );
            }

            public void remove()
            {
                throw new UnsupportedOperationException( "Specification not mutable" );
            }
        };
    }
1176535
public static <T> CloseableIterator<T> concat(final CloseableIterator<? extends Iterator<? extends T>> iterators) {
        return wrap(Iterators.concat(iterators), iterators);
    }
1084174
public static <E> Iterator<E> cycle(Iterator<E> iterator) {
        return new CyclicIterator<E>(iterator);
    }
240118
public Iterator<Symbol> iterator() {
        return scope.getSymbols(t -> !unwanted(t), NON_RECURSIVE).iterator();
    }
217547
public static <E> Iterable<E> cast(final Iterable i) {
        return map(i, new Mapper<Object, E>() {
                public E apply(Object o) {
                    return (E) o;
                }
            });
    }
1249606
public static <T> Iterator<T> singleIterator(T t) {
        Require.nonNull(t, "t");
        return Collections.singleton(t).iterator();
    }
492374
@SuppressWarnings("NullableProblems")
  @Override
  public Iterator<T> iterator() {
    return new Iterator<T>() {
      private int index = 0;

      @Override
      public boolean hasNext() {
        return this.index < size();
      }

      @Override
      public T next() {
        if (this.index >= size()) {
          throw new NoSuchElementException(this.index + ">=" + size());
        }
        return getElementAt(this.index++);
      }

      @Override
      public void remove() {
        throw new UnsupportedOperationException("Removing is unsupported here");
      }

    };
  }