1
2
3
4
5
6 using System;
7 using System.Concepts;
8
9 namespace System.Collections
10 {
11 public class Stack<T> where T is Semiregular
12 {
13 public typedef T ValueType;
14
15 public inline nothrow bool IsEmpty() const
16 {
17 return items.IsEmpty();
18 }
19 public inline nothrow long Count() const
20 {
21 return items.Count();
22 }
23 public inline void Push(const ValueType& item) where T is Copyable
24 {
25 items.Add(item);
26 }
27 public inline void Push(ValueType&& item) where T is Movable
28 {
29 items.Add(item);
30 }
31 public inline ValueType Pop() where T is Movable
32 {
33 return items.RemoveLast();
34 }
35 public inline nothrow const ValueType& Top() const
36 {
37 return items.Back();
38 }
39 public inline nothrow ValueType& Top()
40 {
41 return items.Back();
42 }
43 public inline nothrow void Clear()
44 {
45 items.Clear();
46 }
47 private List<ValueType> items;
48 }
49 }