Optimized the TreeNode constructor (#590)

This commit is contained in:
Sergey Petunin 2016-08-09 18:56:35 +06:00 committed by Grzegorz Piwowarek
parent f73bee24e1
commit f2f2b48782
1 changed files with 3 additions and 4 deletions

View File

@ -1,9 +1,9 @@
package com.baeldung.threadpool;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.google.common.collect.Sets;
public class TreeNode {
int value;
@ -12,8 +12,7 @@ public class TreeNode {
public TreeNode(int value, TreeNode... children) {
this.value = value;
this.children = new HashSet<>();
this.children.addAll(Arrays.asList(children));
this.children = Sets.newHashSet(children);
}
}