Using Set :
static void Job38(Args _args)
{
container c1 = [1,2,2,3,4,5,6,6,7,7,8];
container c2;
Set set = new set(Types::Integer);
SetEnumerator se;
int i;
// Load the containre into the set
for (i=1; i<=conlen(c1); i++)
set.add(conpeek(c1, i)); // Get the enumerator for traversal
se = set.getEnumerator(); // Unload the set back into the c2 container
while (se.moveNext())
c2 += se.current(); // Output the container
info(strfmt("%1", con2str(c2)));
}
Using container :
static void Job38(Args _args)
{
container c1 = [1,2,2,3,4,5,6,6,7,7,8];
container c2;
int i;
int conVal;
for (i=1; i<=conlen(c1); i++)
{
// Store what we find
conVal = conPeek(c1, i); // Search the container to see if it already exists, if not insert
if (confind(c2, conVal) == 0)
{
c2 += conpeek(c1, i);
}
}
static void Job38(Args _args)
{
container c1 = [1,2,2,3,4,5,6,6,7,7,8];
container c2;
Set set = new set(Types::Integer);
SetEnumerator se;
int i;
// Load the containre into the set
for (i=1; i<=conlen(c1); i++)
set.add(conpeek(c1, i)); // Get the enumerator for traversal
se = set.getEnumerator(); // Unload the set back into the c2 container
while (se.moveNext())
c2 += se.current(); // Output the container
info(strfmt("%1", con2str(c2)));
}
Using container :
static void Job38(Args _args)
{
container c1 = [1,2,2,3,4,5,6,6,7,7,8];
container c2;
int i;
int conVal;
for (i=1; i<=conlen(c1); i++)
{
// Store what we find
conVal = conPeek(c1, i); // Search the container to see if it already exists, if not insert
if (confind(c2, conVal) == 0)
{
c2 += conpeek(c1, i);
}
}
Comments
Post a Comment