google/agera

About IdentityMultimap query.

likai79511 opened this issue · 3 comments

capture
according abrove code from agera.
method: addKeyValuePair
purpose: will additation key-pair that same key and different value.
result: we can see the key has exist, so the 'size' will add 1, and because value is no exist, so 'hasValue' still is false, and due to (!hasValue) so the key-pair should be added to array's tail. but result return "size == 0",so return false, actually the key-pair had added to array's tail, right? if yes,I want to know why return false even if had added successfuly?

Thanks
Agera's fans

This package-local IdentityMultimap is not to be taken as a proper util class. Its only use is in WorkerHandler, where we need to maintain a multimap from an Updatable (as key) to the tokens representing different instances of BaseObservables that want to notify the key Updatable of updates.

A return value of true from addKeyValuePair means that the key was unseen from this multimap before the method call. This means that the key Updatable needs to be scheduled. If the key is already in the map (added by other BaseObservables), then it will already have been scheduled.

Actually let me reopen this Q&A, in case you want to follow up. If this answers all your questions, please kindly close this issue. Thanks for your support!

Thanks