You should in real live use bigger value than 1. This is a 'granularity' - how much array gets increased when required. Setting it to one makes not much sense - array will get increased every time you add something.
Thanks for the explanation. Hope this helps Mr. Sinha too. I have used this as an example code and the granularity of one doesn't hinder any processing or so, you are right that everytime when we add an element then the array will increase by one, then thats what I want to do, and moreover it doesn't add any overheads to the processing. I have tried it with diff values, as documented it raises E32USER-CBase 18 panic if we provide negative value.
and moreover it doesn't add any overheads to the processing.
No, that's not true.
An example: You add 10000 entries to an array, in a loop, one after the other. With a granularity of 1 this means that the system de-allocates the old array and allocates a new one 10000 times as well. Allocates are pretty fast, but of course the system also must copy the array content so far from the old array to the new, bigger array.
With a granularity of e.g. 100 there would be 100 times less allocates and copies.
Of course the granularity hardly makes a difference with an array of 10 elements or so, and that's probably the reason why you did not notice any difference, but my example shows that with large arrays a granularity of 1 does add considerable and unneccessary overhead.
It might be the fact as I have used the code for a value of abt 150. It didn't made any significant difference in my application's processing times. Thnx for clearing my concepts.
Forum posts: 84
This is how I have used CDesCArrayFlat in my applications. If you want something specification, then mention that in you post.
//Declaration
CDesCArrayFlat* Carray;
Carray =new (ELeave) CDesCArrayFlat(1);
Carray->Reset();//reseting the array
_LIT(formats,"%S");
value1.Format(formats,&ch);//ch is the value to be added
Carray->AppendL(value1);//adding value to the array
Carray->Delete(2);//will delete the value at index 2
Hope this helps. You can always go to SDK help to check all this and more.
Cheers!!!
Nitin Sahdev
Symbian Developer
Forum posts: 59
You should in real live use bigger value than 1. This is a 'granularity' - how much array gets increased when required. Setting it to one makes not much sense - array will get increased every time you add something.
Forum posts: 84
Thanks for the explanation. Hope this helps Mr. Sinha too. I have used this as an example code and the granularity of one doesn't hinder any processing or so, you are right that everytime when we add an element then the array will increase by one, then thats what I want to do, and moreover it doesn't add any overheads to the processing. I have tried it with diff values, as documented it raises E32USER-CBase 18 panic if we provide negative value.
Cheers!!!
Nitin Sahdev
Symbian Developer
Forum posts: 1321
No, that's not true.
An example: You add 10000 entries to an array, in a loop, one after the other. With a granularity of 1 this means that the system de-allocates the old array and allocates a new one 10000 times as well. Allocates are pretty fast, but of course the system also must copy the array content so far from the old array to the new, bigger array.
With a granularity of e.g. 100 there would be 100 times less allocates and copies.
Of course the granularity hardly makes a difference with an array of 10 elements or so, and that's probably the reason why you did not notice any difference, but my example shows that with large arrays a granularity of 1 does add considerable and unneccessary overhead.
René Brunner
Forum posts: 84
It might be the fact as I have used the code for a value of abt 150. It didn't made any significant difference in my application's processing times.
Thnx for clearing my concepts.
Cheers!!!
Nitin Sahdev
Symbian Developer