user3133542
user3133542

Reputation: 1715

Are there Hash Arrays in Delphi?

Im learning Delphi but loved to use hash arrays in Perl and Java. Are there compairing data structures in Delphi?

I know that It is possible to use TStringList as a Hash Array :

var 
   myHash:TStringList);

begin 

  myHash:=TStringList.Create();
  myHash.values['color']:='blue';

  Showmessage(myHash.Values['color']);  //blue   

  myHash.free;

end;

Is it possible to build more complicated data structures like Perl's hash of arrays etc. in Delphi?

Upvotes: 6

Views: 723

Answers (1)

Mason Wheeler
Mason Wheeler

Reputation: 84550

If you're using Delphi 2009 or later (and hopefully later, because there was a serious bug in the original implementation) you can find the TDictionary class in the Generics.Collections unit. TDictionar<TKey, TValue> functions as a hash-map of keys to values, which should be exactly what you're looking for.

Upvotes: 9

Related Questions