在处理中导入和使用guava collections2

发布于 2025-01-22 03:05:26 字数 868 浏览 1 评论 0原文

我想使用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光无声 2025-01-29 03:05:26

导入的第二个版本是正确的,请com.google.common.collect

The second version of your import is the right one, at com.google.common.collect.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文