internal static List <T> orderedBy <T, R>(Iterable <T> iterable, Function <T, R> getKey) { var result = FromJava.IterableToEnumerable(iterable) .OrderBy(getKey.apply) .ToList(); return(ToJava.ListToList(result)); }
internal static List <T> eagerConcat <T>(Iterable <T> first, Iterable <T> second) { var result = FromJava.IterableToEnumerable(first) .Concat(FromJava.IterableToEnumerable(second)) .ToList(); return(ToJava.ListToList(result)); }
internal static List <U> eagerFlatMap <T, U>(Iterable <T> iterable, Function <T, Iterable <U> > function) { var result = FromJava.IterableToEnumerable(iterable) .SelectMany(element => FromJava.IterableToEnumerable(function.apply(element))) .ToList(); return(ToJava.ListToList(result)); }
internal static List <T> cons <T>(T head, Iterable <T> tail) { var result = new T[] { head } .Concat(FromJava.IterableToEnumerable(tail)) .ToList(); return(ToJava.ListToList(result)); }
internal static List <U> eagerMapWithIndex <T, U>(Iterable <T> iterable, BiFunction <int, T, U> function) { var result = FromJava.IterableToEnumerable(iterable) .Select((value, index) => function.apply(index, value)) .ToList(); return(ToJava.ListToList(result)); }
internal static List <U> eagerMap <T, U>(Iterable <T> iterable, Function <T, U> function) { var result = FromJava.IterableToEnumerable(iterable) .Select(function.apply) .ToList(); return(ToJava.ListToList(result)); }
internal static List <T> eagerFilter <T>(Iterable <T> iterable, Predicate <T> function) { var result = FromJava.IterableToEnumerable(iterable) .Where(function.test) .ToList(); return(ToJava.ListToList(result)); }
internal static Map <K, java.util.List <T> > toMultiMapWithKey <T, K>(Iterable <T> iterable, Function <T, K> function) { var dictionary = FromJava.IterableToEnumerable(iterable) .GroupBy(value => function.apply(value)) .ToDictionary( grouping => grouping.Key, grouping => ToJava.ListToList(grouping.ToList())); return(ToJava.DictionaryToMap(dictionary)); }
internal static Map <K, java.util.List <V> > toMultiMap <T, K, V>(Iterable <T> iterable, Function <T, Map__Entry <K, V> > function) { var dictionary = FromJava.IterableToEnumerable(iterable) .Select(element => function.apply(element)) .GroupBy(entry => entry.getKey()) .ToDictionary( grouping => grouping.Key, grouping => ToJava.ListToList(grouping.Select(entry => entry.getValue()).ToList())); return(ToJava.DictionaryToMap(dictionary)); }
internal static List <T> asList <T>(T[] elements) { return(ToJava.ListToList(elements)); }
internal static List <T> list <T>(params T[] values) { return(ToJava.ListToList(values)); }
internal static List <T> toList <T>(Iterable <T> iterable) { return(ToJava.ListToList(FromJava.IterableToEnumerable(iterable).ToList())); }