public static MapStream map()

in src/main/java/net/hydromatic/lambda/streams/MapStream.java [309:336]


    public static <K, V, W> MapStream<K, W> map(final MapStream<K, V> s,
        final BiMapper<K, 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 k = next.getKey();
                  V v = next.getValue();
                  return BiVal.of(k, mapper.map(k, v));
                }

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