SetIterator.begin Method [AX 2012]
Moves the iterator to the start of the set.
The following example returns set of class IDs of the classes that implement the specified interface, that is, the _id class. An iterator is used to remove classes from the set if they are superclasses, and the _onlyLeafClasses parameter is set to true.
The begin method is used to reset the iterator after the superclasses have been removed from the set.
public static Set getImplements(
classId _id,
boolean _onlyLeafClasses = true)
{
Dictionary dictionary = new Dictionary();
SysDictClass sysDictClass;
boolean removed;
Set set = new Set(Types::Integer);
SetIterator setIterator = new SetIterator(set);
int i;
for (i=1;i<=dictionary.classCnt();i++)
{
sysDictClass = new SysDictClass(dictionary.classCnt2Id(i));
if (sysDictClass.isImplementing(_id))
{
set.add(sysDictClass.id());
}
}
//No superclasses included in return set
if (_onlyLeafClasses)
{
// begin method not needed here; only for clarity
setIterator.begin();
while (setIterator.more())
{
removed = false;
sysDictClass = new SysDictClass(setIterator.value());
while (sysDictClass.extend())
{
removed = removed | set.remove(sysDictClass.extend());
sysDictClass = new SysDictClass(sysDictClass.extend());
}
if (removed)
{
// Restart search
setIterator.begin();
}
else
{
setIterator.next();
}
}
}
return set;
}
Community Additions
ADD
Show: