Page 1 of 1

SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Posted: Wed Dec 23, 2020 2:24 pm
by pikolikoli
Hello Everyone,

I was just testing some code and found a SubsetElementInsert like this :
SubsetDestroy(zDim , zView );
SubsetCreate(zDim, zView );
SubsetElementInsert ( zDim , zView ,'Elem 1', 1 );
SubsetElementInsert ( zDim , zView ,'Elem 2', 1 );
SubsetElementInsert ( zDim , zView ,'Elem 3', 1 );
I found That 1 is the position where we want to insert an element in subset. So what is the difference in behaviour between if I put my subset like this :
SubsetDestroy(zDim , zView );
SubsetCreate(zDim, zView );
SubsetElementInsert ( zDim , zView ,'Elem 1', 1 );
SubsetElementInsert ( zDim , zView ,'Elem 2', 2 );
SubsetElementInsert ( zDim , zView ,'Elem 3', 3 );
Why Are we inserting all the elements on the same position ? woudnt inserting all the elements in the same position erase the last inserted value so we will end up with only Elemnt3 ? and what will happend if we insert them in different position ? When should we use the first case and when should we use the second case ?

Thank you

Re: SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Posted: Wed Dec 23, 2020 2:57 pm
by tomok
Putting 1 as the index means insert it into the first position in the subset. All the other members will be moved down a spot.

Re: SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Posted: Wed Dec 23, 2020 3:22 pm
by pikolikoli
tomok wrote: Wed Dec 23, 2020 2:57 pm Putting 1 as the index means insert it into the first position in the subset. All the other members will be moved down a spot.
Thank you very much I understand Now.

Re: SubsetElementInsert difference between Position Index=1 and =2 in behaviour

Posted: Wed Dec 23, 2020 6:19 pm
by Wim Gielis
Use 0 everywhere if you want to insert elements in the order in which they are listed in the code.