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

Usage as a backend for a SET-like datastructure #8

Open
thestics opened this issue Jul 6, 2023 · 1 comment
Open

Usage as a backend for a SET-like datastructure #8

thestics opened this issue Jul 6, 2023 · 1 comment

Comments

@thestics
Copy link

thestics commented Jul 6, 2023

I want to use your implementation for my data structure.
In particular set would behave like this:

s = set()
s.add(1)
s.add(2)

# Logarithmic search
one_present = 1 in s

# Only one 2 is present
s.add(2)

As you might notice, in this case, the insertion of an already existing Node would just override the existing one, not insert it somewhere else.
Do you think this is a useful addition and should I create a PR with that patch, or you're fine with the current implementation?

Cheers!

@emilydolson
Copy link
Owner

Thanks for the suggestion! The current implementation is intentionally a multi-set (i.e. it allows duplicate elements). Some of the examples in my algorithms class depend on that, so I'd like to keep it that way. However, if you want to add a second data-structure to the library that acts as a set, that would be totally welcome!

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

2 participants