code: public static <T> Stream<Map.Entry<Integer, T>> enumerate(Stream<T> stream) {
          Iterator<Map.Entry<Integer, T>> iterator = new Iterator<Map.Entry<Integer, T>>() {
              private int counter = 0;
              
              private final Iterator<T> internalIterator = stream.iterator();
              
              /** {@inheritDoc} */
              @Override
              public boolean hasNext() {
                  return internalIterator.hasNext();
              }
              
              /** {@inheritDoc} */
              @Override
              public Map.Entry<Integer, T> next() {
                  return new AbstractMap.SimpleImmutableEntry<>(counter++, internalIterator.next());
              }
  
              /** {@inheritDoc} */
              @Override
              public void remove() {
                  throw new UnsupportedOperationException("This is a read-only iterator, remove operation is not supported.");
              }
          };
          return stream(iterator, stream.isParallel());
      }
docs: Takes a stream and enumerates it (similar to Python's enumerate()) to return
  the item along with its position.
  
  @param <T>
  @param stream
  @return