The "Map" allows to associate one value (the key) with another value. Both the key and value can be any valid type.
static void testMap(Args _args)
{
Map m = new Map(Types::STRING, Types::INTEGER);
MapIterator mi;
MapEnumerator me = m.getEnumerator();
int i,test;
str keyId = "abc";
;
m.insert("abc", 37);
m.insert("def", 102);
i = m.lookup("abc");
test = m.exists(keyId)? m.lookup(keyId): 0;
m.insert(keyid, test + 1); // updation
if (m.exists("abc"))
info(strFmt("%1",m.lookup("abc")));
mi = new MapIterator(m);
while (mi.more())
{
info(strFmt("%1 Iterator", mi.key()));
info(strFmt("%1", mi.value()));
mi.next();
}
while (me.moveNext())
{
info(strFmt("%1 Enumertor",me.currentKey()));
info(strFmt("%1",me.currentValue()));
}
}
No comments:
Post a Comment