What is the time complexity
of put()
and get()
in Guava ListMultimap or Guava ArrayListMultimap ?
I have read the below Guava Documentation, However, the time complexity of these operations is not mentioned.
Is the time complexity same as that of Hashmap (O(1)
for both put()
and get()
)?
This is described, though a bit indirectly, on guava's general documentation for multimap. Specifically, in the "Implementations" section, it says that for ArrayListMultimap, the keys behave as HashMap, and the values behave as ArrayList.
Thus, the get and put are both O(1) (with the usual caveats about that claim that accompany HashMap). For get, it's just an O(1) operation that gets the ArrayList; for put, it's that same O(1) get, and then another O(1) put (amortized, as ArrayList additions always are).