PageRenderTime 13ms CodeModel.GetById 10ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

/data/stack.d

http://github.com/wilkie/djehuty
D | 35 lines | 26 code | 9 blank | 0 comment | 0 complexity | 7601e7b1d93b0db5d6cda5af2da3721f MD5 | raw file
 1module data.stack;
 2
 3import data.list;
 4
 5import io.console;
 6
 7class Stack(T) : List!(T) {
 8	this() {
 9		super();
10	}
11
12	this(uint size) {
13		super(size);
14	}
15
16	this(T[] withList) {
17		_data = withList.dup;
18		_count = _data.length;
19	}
20
21	Stack!(T) dup() {
22		return new Stack!(T)(_data[0.._count]);
23	}
24
25	T pop() {
26		T ret;
27		ret = remove();
28
29		return ret;
30	}
31
32	void push(T item) {
33		add(item);
34	}
35}