Skip to content

Commit 81cf727

Browse files
authored
Change newHashSet with newLinkedHashSet for uniq/distinct methods.
1 parent 204a004 commit 81cf727

File tree

2 files changed

+4
-4
lines changed
  • examples/src/main/java/com/github/underscore/examples
  • src/main/java/com/github/underscore

2 files changed

+4
-4
lines changed

examples/src/main/java/com/github/underscore/examples/Xor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
public class Xor {
3434
public static <E> List<E> uniq(final List<E> list) {
35-
return new ArrayList<E>(new HashSet<E>(list));
35+
return new ArrayList<E>(new LinkedHashSet<E>(list));
3636
}
3737

3838
public static <E> Optional<E> find(final Iterable<E> iterable, final Predicate<E> pred) {

src/main/java/com/github/underscore/$.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ public static <E> E[] without(final E[] array, final E ... values) {
10411041
}
10421042

10431043
public static <E> List<E> uniq(final List<E> list) {
1044-
return newArrayList(newHashSet(list));
1044+
return newArrayList(newLinkedHashSet(list));
10451045
}
10461046

10471047
@SuppressWarnings("unchecked")
@@ -2495,8 +2495,8 @@ protected static <T> Set<T> newLinkedHashSet() {
24952495
}
24962496

24972497
@SuppressWarnings("unchecked")
2498-
protected static <T> Set<T> newHashSet(Iterable<T> iterable) {
2499-
final Set<T> result = new HashSet<T>();
2498+
protected static <T> Set<T> newLinkedHashSet(Iterable<T> iterable) {
2499+
final Set<T> result = new LinkedHashSet<T>();
25002500
for (final T item : iterable) {
25012501
result.add(item);
25022502
}

0 commit comments

Comments
 (0)