Whether this is a good idea depends on how often you call
getEntityWithTag(type, tag) |
. Building a proper data-structure allows for retrieval of subsets of data at O(1) instead of O(n), but you pay the price in maintaining these data-structures.
So depending on whether this underlying structure is often written into (adding, removing, changing entities), the current approach may or may not be sensible, performance wise -- design wise it's... a poorly named method, it should be
getFirstEntityWithTag(type, tag) |