The indexes don't change while a vehicle is spawned; if it was index 10 last second, it will be index 10 the coming second IF it's still created and for example traveling on the highway, or some person walking down the street etc.
As for 'Instances'
You don't want the GetinstanceID of the .info object , pretty sure that's 1 unity game object per asset\.info not one per reference, so it's not going to work as a unique id for a 'vehicle\citizen spawn lifetime'. There is no GetHashCode on vehicle instances as they're not unity game objects, just structs sitting in the buffer[]; I guess you meant doing that on the info object which of course the same as above applies.
Getting back to what you're trying to accomplish if I understand this right (paraphrasing here).
Round 1: ... you're looping though vehicle buffer... if flagged 'created' your adding that to your dataset which among other things records the index and positition data of those marked created.
Round 2(and there after):...
You're looping though m_buffer looking for (flag Created) and then seeing if you have this index already.. if you do you're assuming it's the same as before,
if you don't you're assuming it's new, and for each (flagged Deleted) you then are looking through your list for that index an removing it if needed.
That would cover most cases, but of course doesn't cover scenarios were car #10 is active in second 1, but between seconds 1 and 2, car #10n gets despawned, and then a few miliseconds later index 10 is re-used for the spawning of a new totally unrelated car.
Some possible suggestions
1) The no detour option - Do what you're doing plus compare other data
In first pass ( and thereafter) record\update the the m_path #, (m_citizenUnits #,and m_sourceBuilding, and m_targetBuilding, in combo would probably work for some types too if you needed to eliminate even more chance); compare recorded one with current on the next cycle - the chance of the previously mentioned car #10 above despawing and spawning back within one second with the same vehicle buffer index + same m_path index are kind of remote, maybe if you're maxing out vehicles or citizens it might get less remote but it would probably cover 99% of the cases I would think. Anyway, if they're different you treat it as a delete+add situation. I think CitizenInstances could work similarly, chances of same m_citizen id and same m_path changing would be remote... throw in looking up their homebuilding id and it's even less likely.
2) The no detour option 2 - Do what you're doing plus add your own data
Set a unique string on every recognized 'created' for a 'name' via InstanceManager.SetName() or VehicleManager.SetVehicleName() (the latter will set the customname flag correctly I think or you can do it yourself); similar exists for Citizens.
On each cycle when you already have a matching entry on the index in your dataset check InstanceManager.getname() for the object in question, if it matches, then same vehicle, if not then it's a delete+add+setname situation for your own dataset. This should work for vehicles and citizens, as InstanceManager.ReleaseInstance() should get called when each are released so you will know the named-despawns will get wiped out of the dictionary. Obviously this method may not work if it's for publication as people might want to name things; though the fact the CustomName flag exists on the object at all pretty much tells you it's alive and likely not 'new' if you're scanning every second.
3) If this just some local experiment - detour CreateVehicle() and RemoveVehicle() or in the case of remove maybe ReleaseVehicleImplementation() and add calls in the success cases of each for updating your code.
ie
CreateVehicle(out ushort vehicle...bla bla bla )
{
//original code about to return true here
YourMod.AddNewEntry(vehicle);
return true;
}
RemoveVehicle(ushort vehicle)
{
//original code
YourMod.RemoveEntry(vehicle);
return true;
}
4) Another option, is to replace the specific AI createvehicle and releasevehicle functions ((ie PassengerCarAI, BusAI, ResidentAI etc), or in the case of citizens spawn\die function adding similar to the above. Either option may conflict with some existing mods. It's a shame at the moment there isn't an easier way to 'subscribe' to such events.