I have a TObjectDictionary<Integer, TMyObject>
, and TMyObject
has an ID
field that's the key. The dictionary owns the values. The keys originally come from a sequence generator, so as deletes and inserts occur, the key values become non-sequential in the dictionary, and I need them to be sequential. I could pull all the objects into a separate TList
, renumber their ID
s, clear the dictionary and re-add the objects with their now-sequential keys, but that seems awfully inelegant. Is there a better way to do this?
Also, how do I tell a TObjectDictionary
that it no longer owns its values?