List of structures of both TObjects and numbers?

The data I work with is available in the form of objects inheriting TObject, so so far processing it has been very easy to do - I simply used TObjArrays. However, now I would like to store an additional value - a number, to be exact - associated with each of these objects. I’d rather not keep these numbers in a separate array, as that would make it too easy for me to lose synchronisation between the two. TPair looked promising at the first glance, but it can’t hold integers directly and I don’t know what wrapper object to use.

What would be the most efficient way (as well as hopefully demanding minimal changes to the existing code) of achieving this?

Check the TParameter class template.


Excellent! Now, for something I would like to do later: is there something like this which would allow me to store character strings of some sort in it? Apart from the obvious but hack-like solution of using the name field as a value field, of course.

What about TParameter The only trouble, you should create the dictionary for this class yourself. On the other hand you can use

For String with have TObjString.


However much I feel like smacking myself upside the head for not having found this before (at first I thought TObjString didn’t exist in ROOT 4, with which I’m forced to work, but no - it’s on the index all right), you wouldn’t believe how many problems you have just solved for me in addition to the one I had in mind while posting this thread. Thanks a million!