Dictionary that maps values to keys. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.
#include<system/collections/dictionary.h>#include<system/smart_ptr.h>usingnamespaceSystem;usingnamespaceSystem::Collections::Generic;intmain(){// Create the Dictionary-class instance.
autodictionary=MakeObject<Dictionary<int,String>>();// Fill the dictionary.
dictionary->Add(0,u"Foo");dictionary->Add(1,u"Bar");dictionary->Add(2,u"Baz");// Print the dictionary items.
for(constauto&pair:dictionary){std::cout<<pair.get_Key()<<" - "<<pair.get_Value()<<std::endl;}return0;}/*
This code example produces the following output:
0 - Foo
1 - Bar
2 - Baz
*/