Skip to content

Conversation

@petrosagg
Copy link
Contributor

Uses a HashMap to detect duplicates in an iterator and emits them only once. The implemention is similar to the unique() and unique_by() methods but in this case the items are never cloned.

@petrosagg
Copy link
Contributor Author

@jswrenn thanks for taking another look. I just rebased on top of master and I'm happy to resolve the naming as you see fit :)

@petrosagg
Copy link
Contributor Author

@jswrenn should be good to merge now :)

@petrosagg petrosagg changed the title add .duplicate() and .duplicate_by(..) operations add .duplicateσ() and .duplicateσ_by(..) operations Jan 18, 2021
@petrosagg petrosagg changed the title add .duplicateσ() and .duplicateσ_by(..) operations add .duplicates() and .duplicates_by(..) operations Jan 18, 2021
@petrosagg petrosagg force-pushed the duplicate-iter branch 2 times, most recently from 30f749d to 5a620b8 Compare January 20, 2021 12:59
Copy link
Member

@jswrenn jswrenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kudos for unifying the implementations! I just have one last edit for you. :-)

Uses a HashMap to detect duplicates in an iterator and emits them only once. Items are never cloned. Signed-off-by: Petros Angelatos <petrosagg@gmail.com>
@jswrenn jswrenn added this to the next milestone Jan 21, 2021
Copy link
Member

@jswrenn jswrenn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! This PR turned into a really excellent case-study in unifying similar implementations and using internal iteration, that I think will be really informative elsewhere in itertools.

bors r+

@bors bors bot merged commit 853f064 into rust-itertools:master Jan 21, 2021
@bors
Copy link
Contributor

bors bot commented Jan 21, 2021

Build succeeded:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants