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 -

Mailing lists / fpc-pascal / 2006-09
8 messages · 5 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
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 -
Graeme,
I dont know if is the same, but I know that the operations in THashedStringList is sloow, too much unecessary operations, I use TStringHash class for that.
for interfaces:
Look the unit JazzClass.pas in
http://jazz.liws.com.br/download/jazz_a7.zip
for objects:
http://blogs.liws.com.br/cesar/download/ObjectRegister.html I wrote a article in my blog fast add and search objects http://blogs.liws.com.br/cesar/?p=23, sorry still portuguese, but you can look at source code:
[]s
Cesar Romero
For the compiler i created a TFPHashList and TFPHashObjectList as similair to TFPList and TFPObjectList. The code is available in compiler/cutils.pas
Peter
Not in cutils.pas - found them in compiler/cclasses.pas. J
This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you.
Is TFPHashTable the same as Delphi's THashedStringList? I am looking for a List class…
Graeme Geldenhuys ha scritto:
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.
Regards,
Dean
Thanks to all that replied. The string that is going to be stored in the List (with associated object) is a GUID string, so is very random by nature. Would this have any negative affects in the hash table?
I will try it out anyway, I can always swap the internal list out if needed. What I am creating is a Flyweight (design pattern) to store all common objecs I use. I will be fetching the objects based on the OID (GUID) string.
Regards,
- Graeme -
Graeme Geldenhuys ha scritto:
It's a typical use. Choose an appropriate HashTableSize when creating the container (approx.the number of the elements you are going to store or more), you can test it with different hash functions and see through the statistics which one is better (the longer the chains i.e. more void slots, the longer the fetch times).
Dean
Thanks Dean. We are starting off with about 3400 objects and will be growing from there, but not at a rapid pace. Wow, only realized it now. Those objects are math lessons created over the last 8 years. Quite a collection. :-) Oh, and for those wondering, I'm not fully populating all 3400+ objects, they only contain enough information to appear in a treeview. A proxy pattern is used to populate each object only when needed.
Regards,
- Graeme -