Logo

Programming-Idioms

History of Idiom 119 > diff from v28 to v29

Edit summary for version 29 by programming-idioms.org:
[Rust] No sample values

Version 28

2017-08-21, 19:41:42

Version 29

2018-03-09, 13:32:36

Idiom #119 Deduplicate list

Remove duplicates from list x.
Explain if original order is preserved.

Illustration

Idiom #119 Deduplicate list

Remove duplicates from list x.
Explain if original order is preserved.

Illustration
Extra Keywords
deduplicate dupe dupes redundant redundancy
Extra Keywords
deduplicate dupe dupes redundant redundancy
Code
let mut x = vec![1,2,3,4,3,2,2,2,2,2,2];
x.sort();
x.dedup();
Code
x.sort();
x.dedup();
Comments bubble
Deduplication in place. Original order not maintained. Works O(n*log(n))
Comments bubble
Deduplication in place. Original order not maintained. Works O(n*log(n))
Doc URL
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.dedup
Doc URL
https://doc.rust-lang.org/std/vec/struct.Vec.html#method.dedup
Demo URL
https://is.gd/oZBF7w
Demo URL
https://is.gd/oZBF7w