does anyone know a map class where the `Entry` obj...
# announcements
t
does anyone know a map class where the
Entry
objects stay valid when the backing map is modified? I want to hold on to the
Entry
object so I don't have to access the map every time when all I need is that one entry
k
Why can't you access the map every time you need an item from it?
t
Because that's an unnecessary access and entries are accessed potentially many many times. So why not just keep ahold of the entry
k
Pretty much the one thing maps are good at is element access.
t
if you only care about complexity, yes. But the constant cost is high. Every time the hash function has to be computed again. If the
Entry
can be cached, each subsequent access only costs an additional pointer dereference over a regular variable
k
Fair enough.