Reverse for loop not removing isntances.

If you remove an index, some other indexes will be redistributed - jumbled. It does not matter here that you’re doing it in reverse - the indexing within the HISM does not work like a regular array where elements are neatly ordered; they cannot be discarded / (re)moved around while others keep their spot.

You cannot have a situation where there is no index 5 in HISM with 10 instances. The moment you remove 5, number 8 may become 6. :expressionless:

If you want to remove a bunch of indexes, add them to an array and [bulk-remove][1] in one go rather than one-by-one. There are linked examples of this in the other thread where we talked about casting.


Or even better, have a look at how [Sets][2] work - they offer very efficient operations that work really well with HISM indexes. As in:

This way you do not even need to use AddUnique. A Set will ensure values are unique. And there’s no more iteration, it all happens in one go.