Skip to content

Data Structure for Subscribers #8

@linanqiu

Description

@linanqiu

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions