TFPGMap vs TFPGMapInterfacedObjectData lazarus / 21-General ---------------------------------------------------------------------- JdeHaan · 2024-11-12 11:17 I want to create a map of an iUnknown descendant and a variant value. Which map type should I use? TFPGMap or TFPGMapInterfacedObjectData ---------------------------------------------------------------------- Thaddy · 2024-11-12 11:38 It depends on how you use it. Both should be fine. Athough variants are not really my thing: I avoid them when possible. ---------------------------------------------------------------------- JdeHaan · 2024-11-12 16:14 Thanks Thaddy. The Value part in the map can be anything, integer, float, Boolean, char or String. What other solution could there be? ---------------------------------------------------------------------- Thaddy · 2024-11-12 16:18 Well, that is the point: if you use those different data types over the same class instance, you would use a variant, but if you can determine it is the same for the same class instance you would never use a variant, because variants are dead slow, really slow. Which means that, although the map can be reasonably fast, you are stuck with slow code. Note that slow code is not equal to bad code, but you should carefully consider your design. Variants are slow, period. They are not a magic wand. ---------------------------------------------------------------------- PascalDragon · 2024-11-14 20:25 Quote from: JdeHaan on November 12, 2024, 12:17:32 pmI want to create a map of an iUnknown descendant and a variant value. Which map type should I use? TFPGMap or TFPGMapInterfacedObjectData The TFPGMapInterfacedObjectData<,> is intended for interfaces as the data and not the key. So if you want to use Variant as the data then you should use TFPGMap<,>.