aboutsummaryrefslogtreecommitdiff
path: root/Mammoth/Couscous/mammoth/internal/util/Queues.cs
blob: 9bf099c1e57005479f9e0dcbe7029e30f4a44710 (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
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 T remove() {
			var index = _stack.Count - 1;
			var value = _stack[index];
			_stack.RemoveAt(index);
			return value;
		}
	}
}