You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now that the homework's due, I can finally ask this!
Addy Osmani used an array to store subscribers. This makes adding fast, but removing them a rather tedious process. He makes that better using the topic to further segment the subscribers.
I was wondering if there's a way to hash subscribers such that we store them in something like a dictionary with the key being the function, the value being a count of the number of such subscribers. Say function f has x subscribers, then whenever it gets hit, it will emit x times. Removal will simply decrement x until 0, upon which f is removed.
Is that possible? Or as a more general question, is it possible to index by functions?
The text was updated successfully, but these errors were encountered:
Now that the homework's due, I can finally ask this!
Addy Osmani used an array to store subscribers. This makes adding fast, but removing them a rather tedious process. He makes that better using the topic to further segment the subscribers.
I was wondering if there's a way to hash subscribers such that we store them in something like a dictionary with the key being the function, the value being a count of the number of such subscribers. Say function
f
hasx
subscribers, then whenever it gets hit, it will emitx
times. Removal will simply decrementx
until 0, upon whichf
is removed.Is that possible? Or as a more general question, is it possible to index by functions?
The text was updated successfully, but these errors were encountered: