-
笛卡尔乘积
两个集合X和Y的笛卡尓积(Cartesian product),又称直积,表示为X×Y,第一个对象是X的成员而第二个对象是Y的所有可能有序对的其中一个成员。 -
举例
假设集合A={a, b},集合B={0, 1, 2},则两个集合的笛卡尔积为{(a, 0), (a, 1), (a, 2), (b, 0), (b, 1), (b, 2)} -
Java 核心实现
/** * Discription: 笛卡尔乘积算法 * 把一个List{[1,2],[A,B],[a,b]} 转化成 * List{[1,A,a],[1,A,b],[1,B,a],[1,B,b],[2,A,a],[2,A,b],[2,B,a],[2,B,b]} 数组输出 * * @param dimensionValue * 原List * @param result * 通过乘积转化后的数组 * @param layer * 中间参数 * @param currentList * 中间参数 */ public void descartes(List<List<T>> dimensionValue, List<List<T>> result, int layer, List<T> currentL
Java 多List(集合)列表获取笛卡尔积(多数组中所有的排列组合)
于 2019-06-14 15:05:48 首次发布