Skip to content

dlist: Use DoubleEndedIterator #7735

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 4 commits into from
Jul 13, 2013
Merged

dlist: Use DoubleEndedIterator #7735

merged 4 commits into from
Jul 13, 2013

Conversation

bluss
Copy link
Member

@bluss bluss commented Jul 12, 2013

Use DoubleEndedIterator to unify the iterators in extra::dlist. The double-ended iterators are straightforward and the .iter() and .mut_iter() simply use an elements left counter to make sure the iterator terminates at the right point.

Also fix a bug of mine in DList::merge, and DList::insert_ordered not being pub.

@bluss
Copy link
Member Author

bluss commented Jul 12, 2013

I suspect the element counters in the iterators are the reason the iterators also perform slightly better

before

test dlist::tests::bench_iter ... bench: 201 ns/iter (+/- 0)
test dlist::tests::bench_iter_mut ... bench: 292 ns/iter (+/- 3)
test dlist::tests::bench_iter_mut_rev ... bench: 198 ns/iter (+/- 0)
test dlist::tests::bench_iter_rev ... bench: 199 ns/iter (+/- 0)

With patch series

test dlist::tests::bench_iter ... bench: 170 ns/iter (+/- 0)
test dlist::tests::bench_iter_mut ... bench: 174 ns/iter (+/- 6)
test dlist::tests::bench_iter_mut_rev ... bench: 183 ns/iter (+/- 3)
test dlist::tests::bench_iter_rev ... bench: 172 ns/iter (+/- 3)

blake2-ppc added 4 commits July 13, 2013 04:30
Did not properly allow runs from the `other` list to be merged in. The
test case was using a wrong expected value.

Edited docs for merge so they explain more clearly what it does.

Also make sure insert_ordered is marked pub.
Unify the mutable iterators too. Switch the ListInsertion trait to use
method .insert_next() and .peek_next() for list mutation. .insert_next()
inserts an element into the list that will not appear in iteration, of
course; so the length of the iteration can not change during iteration.
@bluss
Copy link
Member Author

bluss commented Jul 13, 2013

Rebased and removed the now unneeded use of the double ended iterator traits.

thestinger added a commit that referenced this pull request Jul 13, 2013
dlist: Use DoubleEndedIterator
@thestinger thestinger merged commit a9eb868 into rust-lang:master Jul 13, 2013
@thestinger
Copy link
Contributor

Spurious failure on the auto-mac-all-opt bot, it keeps happening for unrelated pull requests.

@bluss bluss deleted the dlist branch July 13, 2013 08:30
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