MergeIterator Class

The MergeIterator class encapsulates the behavior required to sequentially access objects from a merged view of two or more compatible dictionary instances. Dictionary instances need not have the same membership but must have at least the first key in common.

In the first example, only the first keys of DictionaryA and DictionaryB are compatible.

In the second example, the first two keys of DictionaryC and DictionaryD are compatible.

When iterating multiple dictionaries, the merged iterator returns objects in key sequence for the compatible keys.

To iterate a single collection, the iterator is created and associated with the collection by using the createIterator method on the collection object. To iterate a merged view of more than one collection, first create the iterator and the addCollection method called for each dictionary to be attached to the iterator, as shown in the following example.

vars
    iter : MergeIterator;
    dict1, dict2 : CustomsByNameAndAddress;
    cust : Customer;
begin
    // Assign dict1 and dict2
    create iter transient;
    iter.addCollection(dict1);
    iter.addCollection(dict2);
    while iter.next(cust) do
        write cust.name;
    endwhile;
end;

For details about the property and methods defined in the MergeIterator class, see "MergeIterator Property" and "MergeIterator Methods", in the following subsections.

Iterator

(None)