diff options
Diffstat (limited to 'dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs')
| -rw-r--r-- | dotnet/Mammoth/Couscous/java/util/ArrayDeque.cs | 35 |
1 files changed, 35 insertions, 0 deletions
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<T> : Deque<T> { + private readonly System.Collections.Generic.IList<T> _list = new System.Collections.Generic.List<T>(); + + 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; + } + } +} |
