// Foreach.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <AcfCorlib.h>
using namespace Acf;
using namespace Acf::Collections;
int _tmain(int argc, _TCHAR* argv[])
{
Console::WriteLine();
//
// Array
//
wcout << L"Array<int>: ";
RefPtr< Array<int> > array = Array<int>::Build(1, 2, 3);
FOREACH (int, n, array)
{
Console::Write(n);
Console::Write(L' ');
}
Console::WriteLine();
Console::WriteLine();
//
// List
//
wcout << L"List<float>: ";
RefPtr< List<float> > list = new List<float>();
list->Add(1.5f);
list->Add(2.5f);
list->Add(3.5f);
FOREACH (float, f, list)
{
Console::Write(f);
Console::Write(L' ');
}
Console::WriteLine();
Console::WriteLine();
//
// Stack
//
wcout << L"Stack<StringPtr>: ";
RefPtr< Stack<StringPtr> > stack = new Stack<StringPtr>();
stack->Push(str(L"one"));
stack->Push(str(L"two"));
stack->Push(str(L"three"));
FOREACH (StringPtr, s, stack)
{
Console::Write(s);
Console::Write(L' ');
}
Console::WriteLine();
Console::WriteLine();
//
// Dictionary
//
wcout << L"Dictionary<StringPtr, int>: ";
RefPtr< Dictionary<StringPtr, int> > map = new Dictionary<StringPtr, int>();
map->Item[str(L"s1")] = 1;
map->Item[str(L"s2")] = 10;
map->Item[str(L"s3")] = 100;
typedef KeyValuePair<StringPtr, int> MapItemType;
FOREACH (MapItemType, item, map)
{
Console::Write(L"(\"{0}\", {1}) ", item.Key, str(item.Value));
}
Console::WriteLine();
Console::WriteLine();
getchar();
return 0;
}