using System;
using System.Collections.Generic;
using System.Text;
namespace Collections
{
///
/// スタック(FILOバッファ)。
///
/// 要素の型
class Stack
{
#region フィールド
ArrayList buffer;
#endregion
#region 初期化
public Stack() { this.buffer = new ArrayList(); }
public Stack(int capacity) { this.buffer = new ArrayList(capacity); }
#endregion
#region 要素の挿入・削除
///
/// 要素のプッシュ。
///
/// 挿入したい要素
public void Push(T elem)
{
this.buffer.InsertLast(elem);
}
///
/// 要素を1つポップ。
///
///
/// 今回の実装では、先頭要素の読み出しと削除は別に行う。
/// この Pop では削除のみ。
/// 読み出しには Top プロパティを使う。
///
public void Pop()
{
this.buffer.EraseLast();
}
///
/// 先頭要素の読み出し。
///
public T Top
{
get { return this.buffer[this.buffer.Count - 1]; }
}
public int Count
{
get { return this.buffer.Count; }
}
#endregion
}
}