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) --- dotnet/Mammoth/Couscous/Adapters.cs | 99 ------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 dotnet/Mammoth/Couscous/Adapters.cs (limited to 'dotnet/Mammoth/Couscous/Adapters.cs') diff --git a/dotnet/Mammoth/Couscous/Adapters.cs b/dotnet/Mammoth/Couscous/Adapters.cs deleted file mode 100644 index c45f35b..0000000 --- a/dotnet/Mammoth/Couscous/Adapters.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System.Collections.Generic; -using System.Linq; -using Mammoth.Couscous.java.lang; -using Mammoth.Couscous.java.util; -using Mammoth.Couscous.java.io; - -namespace Mammoth.Couscous { - internal static class FromJava { - internal static IEnumerable IterableToEnumerable(Iterable iterable) { - Iterator iterator = iterable.iterator(); - while (iterator.hasNext()) { - yield return iterator.next(); - } - } - - internal static IDictionary MapToDictionary(Map map) { - return map.AsDictionary(); - } - } - - internal static class ToJava { - internal static Iterable EnumerableToIterable(IEnumerable enumerator) { - return new IterableWrapper(enumerator); - } - - private class IterableWrapper : Iterable { - private readonly IEnumerable _enumerable; - - internal IterableWrapper(IEnumerable enumerable) { - _enumerable = enumerable; - } - - public Iterator iterator() { - return EnumeratorToIterator(_enumerable.GetEnumerator()); - } - } - - internal static Iterator EnumeratorToIterator(IEnumerator enumerator) { - return new EnumeratorToIteratorAdapter(enumerator); - } - - private class EnumeratorToIteratorAdapter : Iterator { - private readonly IEnumerator _enumerator; - private bool _ready; - private bool _hasNext; - - internal EnumeratorToIteratorAdapter(IEnumerator enumerator) { - _enumerator = enumerator; - _ready = false; - } - - public bool hasNext() { - MakeReady(); - return _hasNext; - } - - public T next() { - MakeReady(); - if (_hasNext) { - _ready = false; - return _enumerator.Current; - } else { - throw new NoSuchElementException(); - } - } - - private void MakeReady() { - if (!_ready) { - MoveNext(); - } - } - - private void MoveNext() { - _hasNext = _enumerator.MoveNext(); - _ready = true; - } - } - - internal static Map DictionaryToMap(IDictionary dictionary) { - return new HashMap(dictionary); - } - - internal static java.util.List ListToList(IList list) { - return new ArrayList(list); - } - - internal static java.io.InputStream StreamToInputStream(System.IO.Stream stream) { - return new StreamToInputStreamAdapter(stream); - } - - private class StreamToInputStreamAdapter : InputStream { - public System.IO.Stream Stream { get; } - - internal StreamToInputStreamAdapter(System.IO.Stream stream) { - Stream = stream; - } - } - } -} -- cgit v1.2.3