Map
------------------
map iim = new map(types::integer, types::class);
mapIterator it;
// Add some elements into the list...
iim.insert(1, new query());
iim.insert(2, new query());
iim.insert(4, new query());
// Create a list iterator
it = new mapIterator (iim);
print it.definitionString(); // prints “[int -> class] iterator”
print it.toString(); // prints “(begin)[(1 -> Query: query object 38824e0)]”
// Go on for as long as elements are found in the set...
while (it.more())
{
// fetch the next element
print it.key(); // prints 4 2 1
print it.value().toString(); // print something like Query object 3881270
it.next();
}
print it.toString(); // prints (end)
pause;
-----------------------------------
Set
------------------
set s1 = new set (types::integer);
int theElement;
setIterator it;
// Add some elements...
s1.add(3);
s1.add(4);
s1.add(13);
s1.add(1);
// Start a traversal of the elements in the set.
it = new setIterator(s1);
// The elements are fetched in the order: 1, 3, 4, 13
print it.toString(); // prints “(begin)[1]”
while (it.more())
{
// Fetch the next element
theElement = it.value();
print theElement;
it.next();
}
pause;
-----------------------------------
List
----------------------
list il = new list(types::integer);
listIterator it;
// Add some elements into the list...
il.addStart(1);
il.addStart(2);
il.addStart(4);
// Create a list iterator
it = new listIterator (il);
print it.definitionString(); // prints “int list iterator”
print it.toString(); // prints “(begin)[4]”
// Go on for as long as elements are found in the list...
while (it.more())
{
// fetch the next element
print it.value(); // prints 4 2 1
it.next();
}
print it.toString(); // prints (end)
pause;