Monday, October 29, 2012

Set


static void  Collection_Set (Args _args)
{
    // Create a new set of type String
    Set cars = new Set (Types :: String);
    SetEnumerator setE;
    ;

    // Add elements to the Set
    cars.add ("Toyota");
    cars.add ("Ford");
    cars.add ("Mazda");
 
    // Check to see if an element exist in the set
    if (cars.in ("Toyota"))
    into ("Toyota is part of the set");
 
    //Display the content of the set
    info (cars.toString());

    // Get the enumerator of the set to loop through it
    setE = cars.getEnumerator();
    while (setE.moveNext())
    {
        info(setE.current());
    }
}

No comments: