A hint about collections

From: Alberto Pulvirenti <alberto.pulvirenti_at_ct.infn.it>
Date: Tue, 22 Feb 2005 13:14:47 +0100

Dear all,

here I ask for a suggestion about which kind of collection object could be better to use.
I am doing a work where, essentially, I collect many similar objects in different collections. After this, I need to process pairs of objects coming from different collections in order to produce a result. What I know is that every new object which I add to the collection, is always put at the end of it (no middle insertions os likely). What I DO NOT know is how many objects I will have to manage for each collection.

Given that I need to reduce the CPU time as much as possible, and I must check also the memory occupation, I would understand what collection object is more suitable for my purposes.

Up to now, I have worked with TObjArray, but I don't know if this object causes memory leaks or just large computing time due to the fact that I don't know the number of elements to collect and I must essentially use the AddLast() method to a TObjArray which has been initialized with the default constructor (without setting any size). Reading the web-guide, I found that for a sequential insertion procedure, the TOrdCollection is better than TList. The question is: is it also better than TObjArray, for a use where I need just to collect all objects and then process them sequentially, in the same order as they were inserted (eventually deleting from the collection the already processed ones, in order to reduce time)?

Thanks and best regards.

        Alberto Received on Tue Feb 22 2005 - 13:10:29 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:05 MET