Suppose if i have Map object I am adding. object in map.
As we know map doesn't allow duplicate keys?
Map<Integer, String> map=new HashMap<>();
map.put(1, "Test");
map.put(2, "Testing");
map.put(1, "Duplicate key");
we know the key(1) is overridden with new value "Duplicate",
How do we find all keys which is overridden ???
And please can you Guys how java handles collision in Map??
Thanks in advance.
j
stuff ;)
a map is a key value storage. there is no specific collision handling this is just a "at this key we want this value".
you cannot find the keys in that way, it does not work like that. this is basic memory handling.
a datastructure should be efficient at it's task. so adding a change vector tracking would break the SRP (single responsibility principle). Because mainly it should just store values and have a certain access behaviour.
you need to add a special structure around that tracks the change vectors. Even there you can have different ways of how changes are tracked -> sequencial, distinct.
does this help ?