From aa03f17c4381c8042007f5462c5a5ff87dc5d932 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 26 Apr 2016 21:11:03 +0100 Subject: Use Deque in XmlParser again --- dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs | 35 +++++++++++++++++++++++++ dotnet/Mammoth/Couscous/java/util/Deque.cs | 10 +++++++ dotnet/Mammoth/Mammoth.csproj | 2 ++ 3 files changed, 47 insertions(+) create mode 100644 dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs create mode 100644 dotnet/Mammoth/Couscous/java/util/Deque.cs (limited to 'dotnet') diff --git a/dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs b/dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs new file mode 100644 index 0000000..df5447d --- /dev/null +++ b/dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs @@ -0,0 +1,35 @@ +namespace Mammoth.Couscous.java.util { + internal class ArrayDeque : Deque { + private readonly System.Collections.Generic.IList _list = new System.Collections.Generic.List(); + + public int size() { + return _list.Count; + } + + public T getFirst() { + if (_list.Count > 0) { + return _list[0]; + } else { + throw new NoSuchElementException(); + } + } + + public T getLast() { + if (_list.Count > 0) { + return _list[_list.Count - 1]; + } else { + throw new NoSuchElementException(); + } + } + + public void add(T value) { + _list.Add(value); + } + + public T removeLast() { + T value = getLast(); + _list.RemoveAt(_list.Count - 1); + return value; + } + } +} diff --git a/dotnet/Mammoth/Couscous/java/util/Deque.cs b/dotnet/Mammoth/Couscous/java/util/Deque.cs new file mode 100644 index 0000000..c954fce --- /dev/null +++ b/dotnet/Mammoth/Couscous/java/util/Deque.cs @@ -0,0 +1,10 @@ +namespace Mammoth.Couscous.java.util { + internal interface Deque { + int size(); + T getFirst(); + T getLast(); + + void add(T value); + T removeLast(); + } +} diff --git a/dotnet/Mammoth/Mammoth.csproj b/dotnet/Mammoth/Mammoth.csproj index 1c17a82..a49035c 100644 --- a/dotnet/Mammoth/Mammoth.csproj +++ b/dotnet/Mammoth/Mammoth.csproj @@ -60,8 +60,10 @@ + + -- cgit v1.2.3