Logo

Programming-Idioms

History of Idiom 119 > diff from v22 to v23

Edit summary for version 23 by bratushka.v:
New Rust implementation by user [bratushka.v]

Version 22

2016-09-27, 16:14:06

Version 23

2016-11-17, 14:29:50

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();
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