在处理中导入和使用guava collections2
我想使用Guava的Collections2的排列方法,如下所示: Arraylist的所有可能排列的ArrayList ,但是很难导入它。我正在使用处理,所以我想知道是否有其他不同的方法来处理处理,或者根本不可能。
这是我想从上面链接进行工作的代码:
import java.util.Collection; //This seems to work
import java.util.Collections2; //This is what I assumed I would need to import but doesn't seem to work
import com.google.common.collect.Collections2; // I also tried this
public void permutations () {
List<Integer> vals = Ints.asList(new int[] {1, 2, 3});
Collection<List<Integer>> orderPerm = Collections2.permutations(vals);
for (List<Integer> val : orderPerm) {
logger.info(val);
}
}
任何帮助都将非常感谢!
I would like to use Guava's Collections2's permutations method as shown here: Get ArrayList of all possible permutations of an ArrayList but am having trouble importing it. I'm using Processing so I am wondering if there is anything different I need to do to use this with Processing, or if it is simply not possible.
This is the code I'm trying to make work from the link above:
import java.util.Collection; //This seems to work
import java.util.Collections2; //This is what I assumed I would need to import but doesn't seem to work
import com.google.common.collect.Collections2; // I also tried this
public void permutations () {
List<Integer> vals = Ints.asList(new int[] {1, 2, 3});
Collection<List<Integer>> orderPerm = Collections2.permutations(vals);
for (List<Integer> val : orderPerm) {
logger.info(val);
}
}
Any help would be much apprecieated thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
导入的第二个版本是正确的,请
com.google.common.collect
。The second version of your import is the right one, at
com.google.common.collect
.