views:

940

answers:

5

Is there similar component for Delphi like dictionary of Python?

I'm now using TStringList to map string/object pairs, but I'd like more general approach and maybe more powerful (TStringList has binary search when it is sorted).

Solutions for pre-D2009 are also welcome.

+8  A: 

There is in Delphi 2009. A whole new containers unit has been added, and a Dictionary class is one of the classes available.

Couple this with Generics, and you have a very powerful set of classes.

Steve
Nice, I didn't know that. One more reason to upgrade.
Scott W
+2  A: 

I haven't tried it myself, but how about this Delphi Collections package? (Thank you Google).

Scott W
+2  A: 

If you are looking for some Hashtable implementations take a look at Hashtable implementations

Gustavo
+1  A: 

I have allways used DeCAL. It includes both sequences, maps and hashtables.

Vegar
It's very nice for prototyping in pre D2009, but dog slow unfortunately.
Marco van de Voort
I have heard people say this, but have never had any problems my self. Maybe because amount of data ain't that large, or that when we started to use it, we compared it to using TStringList... :-/
Vegar
+4  A: 

There is a THashedStringList class (subclassed from TStringList) "hidden" in IniFiles.pas that can significantly speed up searching in a string list based dictionary.

Gerry