container

Hi all,

i have a one doubt on containers. please clarify some one.

i have 2 containers like container1 and container2.

container 1={1,2,2,3,4,5,6,6,7,7,8}

i want to read unique values from container1 and store that values into container2.

please any one help me on this.

Thanks.

moulali.

This is an odd scenario, but I would use a Set collection class (http://msdn.microsoft.com/en-us/library/set.aspx) where values are stored uniquely, and just load/unload it to the next container like such:

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)));

}

hi Alex,

Thanks for your reply. This one is very helpful us. thanks once again.

Regards,

moulali.

Hi Alex,

please suggest without using set how to store container1 values into container2.

Thanks,

moulali.

Hi Alex,

I want only unique values in container1 and store that values into container2.

example.

container con1=[1,1,2,2,3,3.4, 5,6,6,7,7,8,9,9]

so i want to unique values like 1,1,2,2,3,3,6,6,7,7,9,9 in con1 store into container2.

Hi Alex,

I want only unique values in container1 and store that values into container2.

example.

container con1=[1,1,2,2,3,3.4, 5,6,6,7,7,8,9,9]

so i want to unique values like 1,1,2,2,3,3,6,6,7,7,9,9 in con1 store into container2.

so please suggest answer.

thanks

Well how do you want to do it? The most efficient way would be a set (2 lines of code). It starts becoming very inefficient when you use other methods, such as searching the entire container each time for an occurrence if that’s what you want:

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);

}

}

// Output the container

info(strfmt("%1", con2str(c2)));

}