public class Mathematics extends Object
| Constructor and Description |
|---|
Mathematics() |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
combination(List<T> listSouce,
int selected,
Comparator<? super T> comparable,
Consumer<List<T>> consumer)
非递归的组合
|
static <T> boolean |
nextPermutation(List<T> list,
Comparator<? super T> comparable)
编写一个类似C++ STL中的两个关于全排列的函数,分别为next_permutation
|
static <T> void |
permutation(List<T> listSouce,
Comparator<? super T> comparable,
Consumer<List<T>> consumer)
非递归的排列
|
static <T> void |
permutationAndCombination(List<T> listSouce,
int selected,
Comparator<? super T> comparable,
Consumer<List<T>> consumer)
非递归的排列与组合
|
static <T> boolean |
prevPermutation(List<T> list,
Comparator<? super T> comparable)
编写一个类似C++ STL中的两个关于全排列的函数, prev_permutation
这个算法的实现是从C++ STL中抄过来的
|
public static <T> boolean nextPermutation(List<T> list, Comparator<? super T> comparable)
T - 排列数据类型list - 排序列表comparable - 比较函数,更换这个比较函数可以实现等价于 prev_permutation 的算法,这两个是对称的public static <T> boolean prevPermutation(List<T> list, Comparator<? super T> comparable)
T - 排列数据类型list - 排序列表comparable - 比较函数,更换这个比较函数可以实现等价于 nextPermutation 的算法,这两个是对称的public static <T> void permutation(List<T> listSouce, Comparator<? super T> comparable, Consumer<List<T>> consumer)
T - 泛型listSouce - 可 排序的 列表comparable - 比较函数consumer - 消费排序结果public static <T> void combination(List<T> listSouce, int selected, Comparator<? super T> comparable, Consumer<List<T>> consumer)
T - 泛型参数listSouce - 待选择的集合selected - 选择组合的数量comparable - 比较函数,用于去重consumer - 消费者函数,处理输出结果public static <T> void permutationAndCombination(List<T> listSouce, int selected, Comparator<? super T> comparable, Consumer<List<T>> consumer)
T - 泛型参数listSouce - 待选择的集合selected - 选择组合的数量comparable - 比较函数,用于去重consumer - 消费者函数,处理输出结果Copyright © 2024 江苏南大先腾信息产业股份有限公司. All rights reserved.