code: public static <T> Iterable<Indexed<T>> enumerate(Iterable<T> stream) {
          return new Iterable<Indexed<T>>() {
  
              @Override
              public Iterator<Indexed<T>> iterator() {
                  Iterator<T> itr = stream.iterator();
                  return new Iterator<Indexed<T>>() {
  
                      private int i = 0;
  
                      @Override
                      public boolean hasNext() {
                          return itr.hasNext();
                      }
  
                      @Override
                      public Indexed<T> next() {
                          Indexed<T> nextPair = new Indexed<T>(itr.next(), i);
                          i++;
                          return nextPair;
                      }
                  };
              }
          };
      }
docs: Returns an iterable over Index objects that each hold one of the original
  objects of the stream as well its index in the stream