Big-O of containsValue for Guava HashBiMap

1.4k Views Asked by At

I am interested in using a Map that will contain unique keys and values. I also would like to have O(1) complexity for .containsKey() and .containsValue(). To me, it seems like a HashBiMap should be able to support this complexity because of the uniqueness of both the keys and values in the map and hashing. Is this a correct assumption?

1

There are 1 best solutions below

2
On BEST ANSWER

A PROPERLY IMPLEMENTED two-way HashMap (In this case, a HashBiMap) indeed has a runtime complexity of O(1) for containsKey and containsValue.