DEV Community

Discussion on: Data Structures: Bidirectional Map

 
pretaporter profile image
Maksim

If you go over implementation, you will see that it is not possible that updation of one map can fail.

Should not be any issue with using non primitive values.

Complexity of searching key or value will be constant O(1);

Thread Thread
 
dean profile image
dean

I think the confusion comes from how errors occur - errors do not simply happen randomly, they happen for reasons. A map update should never result in an error occurring, maybe except some kind of fatal error like an out-of-memory error, in which case the program will not be able to work properly anyway.

Updating a map is (pretty much) as safe as creating an array - we don’t need, or want, to error check it.