[fpc-pascal] THashedStringList vs TFPHashTable

Dean Zobec dezobec at tin.it
Wed Sep 27 18:58:20 CEST 2006

Graeme Geldenhuys ha scritto:
> Hi,
> Is TFPHashTable the same as Delphi's THashedStringList?
> I am looking for a List class that can hold large amounts of objects
> with a ID string associated for quick lookups.
> Regards,
>  - Graeme -

Yes, similar to a THashedStringList, but with a special implementation
The TFPHashTable was highly optimized with a lot of profiling, while
trying to achieve the ease of use through object orientation and ease of
maintainance. It's a hash table with a customizable hash function (to
achieve constant performance in searches), chaining is used as a
collision resolution scheme. Some statistics are also provided to be
able to choose the appropriate hash function and the appropriate hash
table size.
The difference in performance with respect to a simple ordered
TStringList is evident when more then 100.000 elements are added to the
container, the number of elements the container can hold is huge
(longword, and obviously ram size, is the limit :). I have another idea
to further improve the performance of searches and I'm planning to
further profile it in the next weeks to see if there are other speed gains.
Be aware that the version in 2.0.4 and before contains a bug that was
solved by Marco in 2.1.1. and merged in 2.0.5 (an AV if the insertion is
made after a clear) due to the use of longwords in the for cycles.
I'm attaching the fpcunit tests for you to see how to use it, and I'll
give you all the assistance that you need. I'll be glad to receive some
feedback as usual.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: testfphashtable.pp
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20060927/d75328bf/attachment.ksh>

More information about the fpc-pascal mailing list