// Path: backport/src/java/util/function/Consumer.java
// public interface Consumer<T> {
//   public void accept(T element);
// }
// 
// Path: backport/src/java/util/function/Function.java
// public interface Function<T, U> {
//   public U apply(T element);
// }
// 
// Path: backport/src/java/util/function/IntFunction.java
// public interface IntFunction<T> {
//   public T apply(int value);
// }
// 
// Path: backport/src/java/util/function/Predicate.java
// public interface Predicate<T> {
//   boolean test(T element);
// }
// 
// Path: backport/src/java/util/stream/Collector.java
// public interface Collector<T, A, R> {
//   public R doCollect(Stream<T> stream);
// }
// 
// Path: backport/src/java/util/stream/Collectors.java
// public class Collectors {
//   public static <T, K, V> Collector<T, ?, Map<K,V>> toMap(Function<? super T, ? extends K> keyMapper,
//                                                           Function<? super T, ? extends V> valueMapper) {
//     return stream -> {
//       HashMap<K, V> map = new HashMap<>();
//       stream.forEach(element -> {
//         map.put(keyMapper.apply(element), valueMapper.apply(element));
//       });
//       return map;
//     };
//   }
// 
//   public static <T> Collector<T, ?, Set<T>> toSet() {
//     return toCollection(HashSet::new);
//   }
//   
//   public static <T> Collector<T, ?, List<T>> toList() {
//     return toCollection(ArrayList::new);
//   }
//   
//   private static <T, C extends Collection<T>> Collector<T, ?, C> toCollection(Supplier<C> collectionFactory) {
//     return stream -> {
//       C collection = collectionFactory.get();
//       stream.forEach(collection::add);
//       return collection;
//     };
//   }
// }
// 
// Path: backport/src/java/util/stream/Stream.java
// public interface Stream<T> {
//   public void forEach(Consumer<? super T> consumer);
//   public Stream<T> filter(Predicate<? super T> predicate);
//   public Stream<T> sorted();
//   public <A> A[] toArray(IntFunction<A[]> generator);
//   public <R, A> R collect(Collector<T, A, R> collector);
//   public <U> Stream<U> map(Function<? super T, ? extends U> mapper);
//   public Stream<T> distinct();
//   public Stream<T> sorted(Comparator<? super T> comparator);
// }


import java.lang.invoke.CallSite;
import java.lang.invoke.ConstantCallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandleProxies;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;
package rt;



public class Enhancements {
  // --- entry points
  
  public static <T> Stream<T> stream(List<T> list) {
    return streamImpl(list);
  }
  public static <T> Stream<T> stream(Set<T> list) {
    return streamImpl(list);
  }
  public static <T> Function<T,T> identity() {
    return x -> x;
  }
  
  
  // --- implementations
  
  private static <T> StreamImpl<T> streamImpl(Iterable<? extends T> iterable) {
    return new StreamImpl<T>() {
      @Override
      public void forEach(Consumer<? super T> consumer) {
        for(T element: iterable) {
          consumer.accept(element);
        }
      }
    };
  }
  
  static abstract class StreamImpl<T> implements Stream<T> {
    @Override
    public abstract void forEach(Consumer<? super T> consumer);
    
    @Override
// Path: backport/src/java/util/function/Consumer.java
// public interface Consumer<T> {
//   public void accept(T element);
// }
// 
// Path: backport/src/java/util/function/Function.java
// public interface Function<T, U> {
//   public U apply(T element);
// }
// 
// Path: backport/src/java/util/function/IntFunction.java
// public interface IntFunction<T> {
//   public T apply(int value);
// }
// 
// Path: backport/src/java/util/function/Predicate.java
// public interface Predicate<T> {
//   boolean test(T element);
// }
// 
// Path: backport/src/java/util/stream/Collector.java
// public interface Collector<T, A, R> {
//   public R doCollect(Stream<T> stream);
// }
// 
// Path: backport/src/java/util/stream/Collectors.java
// public class Collectors {
//   public static <T, K, V> Collector<T, ?, Map<K,V>> toMap(Function<? super T, ? extends K> keyMapper,
//                                                           Function<? super T, ? extends V> valueMapper) {
//     return stream -> {
//       HashMap<K, V> map = new HashMap<>();
//       stream.forEach(element -> {
//         map.put(keyMapper.apply(element), valueMapper.apply(element));
//       });
//       return map;
//     };
//   }
// 
//   public static <T> Collector<T, ?, Set<T>> toSet() {
//     return toCollection(HashSet::new);
//   }
//   
//   public static <T> Collector<T, ?, List<T>> toList() {
//     return toCollection(ArrayList::new);
//   }
//   
//   private static <T, C extends Collection<T>> Collector<T, ?, C> toCollection(Supplier<C> collectionFactory) {
//     return stream -> {
//       C collection = collectionFactory.get();
//       stream.forEach(collection::add);
//       return collection;
//     };
//   }
// }
// 
// Path: backport/src/java/util/stream/Stream.java
// public interface Stream<T> {
//   public void forEach(Consumer<? super T> consumer);
//   public Stream<T> filter(Predicate<? super T> predicate);
//   public Stream<T> sorted();
//   public <A> A[] toArray(IntFunction<A[]> generator);
//   public <R, A> R collect(Collector<T, A, R> collector);
//   public <U> Stream<U> map(Function<? super T, ? extends U> mapper);
//   public Stream<T> distinct();
//   public Stream<T> sorted(Comparator<? super T> comparator);
// }


// Path: backport/src/rt/Enhancements.java
import java.lang.invoke.CallSite;
import java.lang.invoke.ConstantCallSite;
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandleProxies;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.invoke.MethodHandles.Lookup;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

package rt;



public class Enhancements {
  // --- entry points
  
  public static <T> Stream<T> stream(List<T> list) {
    return streamImpl(list);
  }
  public static <T> Stream<T> stream(Set<T> list) {
    return streamImpl(list);
  }
  public static <T> Function<T,T> identity() {
    return x -> x;
  }
  
  
  // --- implementations
  
  private static <T> StreamImpl<T> streamImpl(Iterable<? extends T> iterable) {
    return new StreamImpl<T>() {
      @Override
      public void forEach(Consumer<? super T> consumer) {
        for(T element: iterable) {
          consumer.accept(element);
        }
      }
    };
  }
  
  static abstract class StreamImpl<T> implements Stream<T> {
    @Override
    public abstract void forEach(Consumer<? super T> consumer);
    
    @Override
    public Stream<T> filter(Predicate<? super T> predicate) {