stack: STL/CLR版Stack<T>
毎度おなじみ FILO(First In Last Out: 先入れ後出し)バッファ。
#include <cliext/stack>
using namespace System;
using namespace System::Collections::Generic;
using namespace cliext;
int main() {
stack<String^> s;
for each ( String^ item in
gcnew array<String^> { L"one", L"two", L"three", L"four" } ) {
s.push(item);
}
// stackが内包するコンテナを参照する
for each ( String^ item in s.get_container() ) {
Console::WriteLine(item);
}
while ( !s.empty() ) {
Console::WriteLine(s.top()); // stackの先頭
s.pop(); // pop() の戻り値はvoid つまり先頭要素を廃棄する
}
return 0;
}