Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Std::multimap equivalent in delphi

I am currently looking for a way to store tuples of a Key (GUID) and several Objects (all of the same type) in a hashmap.

My approach was to define a new generic type like this:

type TMultiMap<T, V> = TDictonary<T, TObjectList<V>>; //FAILS,

but this is rejected by the compiler.

Is there a readymade multimap implementaion available in Delphi 2010? If not, how can I create one?

like image 408
sum1stolemyname Avatar asked Aug 22 '26 02:08

sum1stolemyname


1 Answers

That doesn't compile, but this does:

type TMultiMap<T, V: class> = class(TDictionary<T, V>);

But if you want a "real" multimap instead of building an ad-hoc one, check out DeHL. It's got several useful container libraries, including a handful of multimap implementations.

like image 75
Mason Wheeler Avatar answered Aug 24 '26 01:08

Mason Wheeler