google / agera

Reactive Programming for Android
Apache License 2.0
7.2k stars 639 forks source link

About IdentityMultimap query. #162

Closed likai79511 closed 7 years ago

likai79511 commented 7 years ago

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

maxtroy commented 7 years ago

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.

maxtroy commented 7 years ago

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!

likai79511 commented 7 years ago

Thanks