Logo

Programming-Idioms

History of Idiom 119 > diff from v13 to v14

Edit summary for version 14 by :
[Java] Original ordering is not preserved.

Version 13

2016-02-17, 13:19:51

Version 14

2016-02-18, 16:58:03

Idiom #119 Deduplicate list

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

Idiom #119 Deduplicate list

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

Imports
import std.container;
import std.array;
Imports
import std.container;
import std.array;
Code
x = redBlackTree(x)[].array;
Code
x = redBlackTree(x)[].array;
Comments bubble
Converts to a set then back to an array
Comments bubble
Converts to a set then back to an array
Doc URL
http://dlang.org/phobos/std_container_rbtree.html#.redBlackTree
Doc URL
http://dlang.org/phobos/std_container_rbtree.html#.redBlackTree
Imports
import java.util.HashSet;
import java.util.ArrayList;
Imports
import java.util.HashSet;
import java.util.ArrayList;
Code
x = new ArrayList<T>(new HashSet<T>(x));
Code
x = new ArrayList<T>(new HashSet<T>(x));
Comments bubble
This creates a new ArrayList object.
Original ordering is not preserved.
Comments bubble
This creates a new ArrayList object.
Original ordering is not preserved.