From 45e530dceda42282fae56b4c4f5fa7865f57899d Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Sat, 4 Jun 2016 16:03:56 +0100 Subject: Remove dotnet (use submodule from dotnet repo instead) --- .../Couscous/mammoth/internal/util/Lists.cs | 97 ---------------------- 1 file changed, 97 deletions(-) delete mode 100644 dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs (limited to 'dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs') diff --git a/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs b/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs deleted file mode 100644 index b914a34..0000000 --- a/dotnet/Mammoth/Couscous/mammoth/internal/util/Lists.cs +++ /dev/null @@ -1,97 +0,0 @@ -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.util.function; -using System.Linq; - -namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util { - internal static class Lists { - internal static List list(params T[] values) { - return ToJava.ListToList(values); - } - - internal static List toList(Iterable iterable) { - return ToJava.ListToList(FromJava.IterableToEnumerable(iterable).ToList()); - } - - internal static List eagerMap(Iterable iterable, Function function) { - var result = FromJava.IterableToEnumerable(iterable) - .Select(function.apply) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List eagerFlatMap(Iterable iterable, Function> function) { - var result = FromJava.IterableToEnumerable(iterable) - .SelectMany(element => FromJava.IterableToEnumerable(function.apply(element))) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List cons(T head, Iterable tail) { - var result = new T[] { head } - .Concat(FromJava.IterableToEnumerable(tail)) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List eagerConcat(Iterable first, Iterable second) { - var result = FromJava.IterableToEnumerable(first) - .Concat(FromJava.IterableToEnumerable(second)) - .ToList(); - return ToJava.ListToList(result); - } - - internal static List orderedBy(Iterable iterable, Function getKey) { - var result = FromJava.IterableToEnumerable(iterable) - .OrderBy(getKey.apply) - .ToList(); - return ToJava.ListToList(result); - } - - internal static Optional tryGetLast(List list) { - if (list.isEmpty()) { - return new None(); - } else { - return new Some(list.get(list.size() - 1)); - } - } - - internal static Iterable reversed(List list) { - return new ReversedList(list); - } - - private class ReversedList : Iterable { - private readonly List _list; - - internal ReversedList(List list) { - _list = list; - } - - public Iterator iterator() { - return new ReverseIterator(_list); - } - } - - private class ReverseIterator : Iterator { - private readonly List _list; - private int _nextIndex; - - internal ReverseIterator(List list) { - _list = list; - _nextIndex = _list.size() - 1; - } - - public bool hasNext() { - return _nextIndex >= 0; - } - - public T next() { - if (hasNext()) { - return _list.get(_nextIndex--); - } else { - throw new NoSuchElementException(); - } - } - } - } -} -- cgit v1.2.3