Monday, October 29, 2012

Map


static void Collection_Map (Args _args)
{
    // Create a new map with a key and value type
    Map cars = newMap (Types :: Integer, Type :: String);
    MapEnumerator mapE;

    ;
    // Insert values to the map
    cars.insert (1, "Volvo");
    cars.insert (2, "BMW");
    cars.insert (3, "Chrysler");
    //Display the content of the map
    info (cars.toString()) ;
    // Get the enumerator to loop
    // through the elements of the map
    mapE = cars.getEnumerator();
    while (mapE.moveNext())
    {
        info (strfmt ("Car %1: %2, mapE.currentKey(), mapE.currentKey());
    }
}

No comments: