Skip to content

Implement union, intersection, and difference functions for TrieSet. #19296

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

Merged
merged 1 commit into from
Nov 27, 2014

Conversation

csouth3
Copy link
Contributor

@csouth3 csouth3 commented Nov 25, 2014

TrieSet doesn't yet have union, intersection, difference, and symmetric difference functions implemented. Luckily, TrieSet is largely similar to TreeSet, so I was able to reference the implementations of these functions in the latter, and adapt them as necessary to make them work for TrieSet.

One thing that I thought was interesting is that the Iterator yielded by iter() for TrieSet iterates over the set's values directly rather than references to the values (whereas I think in most cases I see the Iterator given by iter() iterating over immutable references), so for consistency within TrieSet's interface, all of these Iterators also iterate over the values directly. Let me know if all of these should be instead iterating over references.

@Gankra
Copy link
Contributor

Gankra commented Nov 25, 2014

Yes, although we do currently store the integers in their entirety, strictly speaking a Trie doesn't necessarily do that. So yielding keys by value is probably The Right Thing.

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Nov 27, 2014
TrieSet doesn't yet have union, intersection, difference, and symmetric difference functions implemented.  Luckily, TrieSet is largely similar to TreeSet, so I was able to reference the implementations of these functions in the latter, and adapt them as necessary to make them work for TrieSet.

One thing that I thought was interesting is that the Iterator yielded by `iter()` for TrieSet iterates over the set's values directly rather than references to the values (whereas I think in most cases I see the Iterator given by `iter()` iterating over immutable references), so for consistency within TrieSet's interface, all of these Iterators also iterate over the values directly.  Let me know if all of these should be instead iterating over references.
@bors bors merged commit 2a6f197 into rust-lang:master Nov 27, 2014
@csouth3 csouth3 deleted the trieset-union branch November 27, 2014 06:38
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

Successfully merging this pull request may close these issues.

3 participants