/**
* Get Combinations (C (superscript, subscript))
*@paramTotalCountNormal data node group count except primary data node group
*@paramSelectCountSecondary data node count
*@returnThe possibility of combinations
* e.g. the possibility of select 2 members from 5 members
* The possibility: {[5,4], [5,3], [5,2], [5,1], [4,3], [4,2], [4,1], [3,2], [3,1], [2,1]}
*/
Private list<deque<integer>>Getcombination (int TotalCount, int selectcount) {
The combination of secondary count from group Count which expect primary group.
int comb[] =New int[selectcount+1];
comb[0] = SelectCount;
List<deque<integer>> resultindexlist =New Arraylist<> ();
Combination (comb, TotalCount, SelectCount, resultindexlist);
Logger.info ("Secondary group Index combination:{}", resultindexlist);
Return resultindexlist;
}
/**
* Get Combinations (C (superscript, subscript))
* e.g. C (5, 2), the resultlist: {[5,4], [5,3], [5,2], [5,1], [4,3], [4,2], [4,1], [3,2], [3,1], [2,1]}
*@paramCombLast result of combination
*@paramSuperscriptMax of the number
*@paramSubscriptSelect numbers count
*@paramResultlistResult after combination
*/
private voidCombination (int comb[], int superscript, int subscript, list<deque<integer>> resultlist) {
for (int i = superscript; I >= subscript; i--) {
Select Current HEAD element
Comb[subscript] = i;
if (Subscript >1) {
Enter next smaller combination
Combination (comb, I-1, subscript-1;
} else {
Deque<integer> selectindexqueue = Span style= "COLOR: #cc7832" >new arraydeque<> () //save combination
Span style= "COLOR: #cc7832" >for (int j=comb[0]; J>0 Selectindexqueue.add (comb[j]) ;
}
Resultlist.add (selectindexqueue) ;
}
}
return;
}
/span>
Combinatorial algorithm (similar to C (5,2))