Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Structure for Subscribers #8

Open
linanqiu opened this issue Feb 9, 2015 · 0 comments
Open

Data Structure for Subscribers #8

linanqiu opened this issue Feb 9, 2015 · 0 comments

Comments

@linanqiu
Copy link

linanqiu commented Feb 9, 2015

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant