public void collectionClasses()
{
//1. List
//To add values to the list
List lst = new List(Types::String);
lst.addEnd(“Value-1”);
lst.addEnd(“Value-2”);
lst.addStart(“Value-3”);
lst.addEnd(“Value-4”);
//Ouput: Value-3, Value-1, Value-2, Value-4
//Enumerate the list
ListEnumerator lstEnumerator = lst.getEnumerator();
while (lstEnumerator.moveNext())
{
info(lstEnumerator.current()); //Current value of the list
}
//List usage - List of all Devlivered service records
POLMobileServiceTable polMobileServiceTable;
List lstDelivered = new List(Types::String);
while select * from polMobileServiceTable
where polMobileServiceTable.ServiceStatus == POLServiceStatus::Delivered
{
lstDelivered.addEnd(polMobileServiceTable.ServiceID);
}
//2. Set
Set mySet = new Set(Types::String);
mySet.add("Value-3");
mySet.add("Value-2");
mySet.add("Value-1");
mySet.add("Value-4");
//Output: Value-1, Value-2, Value-3, Value-4
//Iterate the set
SetEnumerator setEnum = mySet.getEnumerator();
while(setEnum.moveNext())
{
info (setEnum.current()); //Current value of the set.
}
//Set usage - List of all Devlivered service records
POLMobileServiceTable polMobileServiceTable;
Set setDelivered = new Set(Types::String);
while select * from polMobileServiceTable
where polMobileServiceTable.ServiceStatus == POLServiceStatus::Delivered
{
setDelivered.add(polMobileServiceTable.ServiceID); //Service IDs willbe arranged in alphabetical order.
}
//Functions of set
//Set::union(set1, set2)
//Set::difference(set1, set2)
//Set::intersection(set1, set2)
//3. Map - Hashtable (Key, Value pair)
Map myMap = new Map(Types::String, Types::Real);
myMap.add("Value1", 1234.92);
myMap.add("Value2", 123.92);
myMap.add("Value3", 15.92);
//Iterate map
MapEnumerator mapEnum = myMap.getEnumerator();
while (mapEnum.moveNext())
{
info (strFmt("Key: %1, Value: %2", mapEnum.currentKey(), mapEnum.currentValue());
}
//Retrieve value from map
real amount = myMap.lookup("Value1"); //1234.92
//Exists in map
if (myMap.exists("Value4") //No error will be thrown since Value 4 is not available
{
real amount1 = myMap.lookup("Value4"); //1234.92
}
}