Optimized the TreeNode constructor (#590)
This commit is contained in:
parent
f73bee24e1
commit
f2f2b48782
|
@ -1,9 +1,9 @@
|
||||||
package com.baeldung.threadpool;
|
package com.baeldung.threadpool;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
|
||||||
public class TreeNode {
|
public class TreeNode {
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
|
@ -12,8 +12,7 @@ public class TreeNode {
|
||||||
|
|
||||||
public TreeNode(int value, TreeNode... children) {
|
public TreeNode(int value, TreeNode... children) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.children = new HashSet<>();
|
this.children = Sets.newHashSet(children);
|
||||||
this.children.addAll(Arrays.asList(children));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue