Logo

Programming-Idioms

History of Idiom 119 > diff from v23 to v24

Edit summary for version 24 by programming-idioms.org:
[Rust] +DemoURL

Version 23

2016-11-17, 14:29:50

Version 24

2016-11-17, 16:36:24

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