PDA

View Full Version : c++ vector = ? delphi



virtual
09-06-2010, 05:46 PM
hi all

i am looking for a delphi containers like in c++ ( STL library )
in experts-exchange they said that Tlist is very slow comparing to c++ vector

VilleK
09-06-2010, 06:24 PM
In Delphi 2009 and 2010 you have the unit Generics.Collections for generic (template) style containers:

IList : TList<integer>;
OList : TObjectList<TMyClass>;
etc.

In older Delphi you have TList and also TObjectList (in contnrs unit).

Lists in Delphi are implemented the same as stl Vectors: they are array-based. And since data structure are the same then also performance should be comparable. Sure a good C++ compiler generates faster code than Delphi but you should not notice any big difference.

virtual
10-06-2010, 12:24 PM
thnx for the Illustration
i've done a small test between Tlist and c++ vector

its an addition of 3000000 records of 16 byte length, in one loop

Tlist time = 344ms
Vector time = 339ms

seems they are the same
the test use only the function ( List.add , vector.push_back) i don't know how it will be in sorting or other function