aboutsummaryrefslogtreecommitdiff
path: root/Mammoth/Couscous/mammoth/internal/util/Queues.cs
blob: 325b29acb09531aa8ee84a2d589e17c0474c7d48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using Mammoth.Couscous.java.util;
using System;

namespace Mammoth.Couscous.org.zwobble.mammoth.@internal.util
{
	internal static class Queues {
		internal static Queue<T> stack<T>()	 {
			return new Stack<T>();
		}
	}

	internal class Stack<T> : Queue<T> {
		private readonly System.Collections.Generic.IList<T> _stack = new System.Collections.Generic.List<T>();

		public Iterator<T> iterator() {
			return ToJava.EnumeratorToIterator(_stack.GetEnumerator());
		}

		public void add(T value) {
			_stack.Add(value);
		}

		public bool isEmpty() {
			return _stack.Count == 0;
		}

		public T remove() {
			var index = _stack.Count - 1;
			var value = _stack[index];
			_stack.RemoveAt(index);
			return value;
		}
	}
}