public static MapStream mapValues()

in src/main/java/net/hydromatic/lambda/streams/MapStream.java [250:277]


    public static <K, V, W> MapStream<K, W> mapValues(final MapStream<K, V> s,
        final Mapper<V, W> mapper) {
      return new AbstractMapStream<K, W>() {
        public Iterable<BiValue<K, W>> asIterable() {
          return new Iterable<BiValue<K, W>>() {
            public Iterator<BiValue<K, W>> iterator() {
              final Iterator<BiValue<K, V>> x = s.iterator();
              return new Iterator<BiValue<K, W>>() {
                public boolean hasNext() {
                  return x.hasNext();
                }

                public BiValue<K, W> next() {
                  BiValue<K, V> next = x.next();
                  K key = next.getKey();
                  V value = next.getValue();
                  return BiVal.of(key, mapper.map(value));
                }

                public void remove() {
                  x.remove();
                }
              };
            }
          };
        }
      };
    }