I think that after introducing Id.index(), the equals() method needs to be changed. Re-using Id objects for different generic types than the one they were generated for may lead to having many Ids with the same id, but a different index.
Comparing both index and id may be an option, but since this may break existing (dirty) code, I suggest to take a bigger leap and switch to this check `this == obj`.
However the above gets solved, both `IdMap` and `IdSet` will still malfunction if Ids are reused for a different type. The only way to fix it is to add `T class` as a field in Id.
Well, maybe this is only a problem of the "dirty" reuse-Id code. And we should not guarantee that dirty code always works. But then what about switching to `this == obj` for the equals() method??