custom-permutation 1.0.6 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +92 -44
- package/lib/CustomPermutation.d.ts +2 -3
- package/lib/CustomPermutation.js +19 -60
- package/lib/CustomPermutation.js.map +1 -1
- package/lib/CustomPermutationGenerator.d.ts +7 -19
- package/lib/CustomPermutationGenerator.js +111 -165
- package/lib/CustomPermutationGenerator.js.map +1 -1
- package/lib/PermutationGeneratorForSet.d.ts +10 -17
- package/lib/PermutationGeneratorForSet.js +124 -242
- package/lib/PermutationGeneratorForSet.js.map +1 -1
- package/lib/index.js +10 -1
- package/lib/index.js.map +1 -1
- package/package.json +4 -4
- package/lib/Enums.d.ts +0 -39
- package/lib/Enums.js +0 -49
- package/lib/Enums.js.map +0 -1
- package/lib/Permutation.d.ts +0 -26
- package/lib/Permutation.js +0 -265
- package/lib/Permutation.js.map +0 -1
- package/lib/Utils.d.ts +0 -4
- package/lib/Utils.js +0 -34
- package/lib/Utils.js.map +0 -1
|
@@ -1,169 +1,125 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomPermutationGenerator = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function CustomPermutationGenerator(elementList, choicesByIndex, // ChoicesByIndex is relative to sub-sch so we need elementsIndexRel, a index list of sub-sch
|
|
8
|
-
nonChoicesByIndex, // nonChoices is also relative
|
|
9
|
-
elementsOrderAbs, // Actual orders in final schdule
|
|
10
|
-
elementsIndexRel, // Actual relative orders in sub-schedule
|
|
11
|
-
passFunction, randomizechoices) {
|
|
12
|
-
var _this = this;
|
|
13
|
-
if (choicesByIndex === void 0) { choicesByIndex = {}; }
|
|
14
|
-
if (nonChoicesByIndex === void 0) { nonChoicesByIndex = {}; }
|
|
15
|
-
if (elementsIndexRel === void 0) { elementsIndexRel = []; }
|
|
4
|
+
const PermutationGeneratorForSet_1 = require("./PermutationGeneratorForSet");
|
|
5
|
+
class CustomPermutationGenerator {
|
|
6
|
+
constructor(elementList, choicesByIndex = {}, nonChoicesByIndex = {}, elementsOrderAbsolute, passFunction) {
|
|
16
7
|
this.elementList = elementList;
|
|
17
8
|
this.choicesByIndex = choicesByIndex;
|
|
18
9
|
this.nonChoicesByIndex = nonChoicesByIndex;
|
|
19
|
-
this.
|
|
20
|
-
this.elementsIndexRel = elementsIndexRel;
|
|
10
|
+
this.elementsOrderAbsolute = elementsOrderAbsolute;
|
|
21
11
|
this.passFunction = passFunction;
|
|
22
|
-
this.randomizechoices = randomizechoices;
|
|
23
12
|
this.nextIndexList = [];
|
|
24
|
-
this.
|
|
25
|
-
this.history = [];
|
|
26
|
-
this.historyHashes = [];
|
|
27
|
-
this.current = [];
|
|
13
|
+
this.finalChoicesByIndexInSet = {};
|
|
14
|
+
this.history = [];
|
|
15
|
+
this.historyHashes = [];
|
|
16
|
+
this.current = [];
|
|
28
17
|
this.cursor = 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
var indexesOfSameElements = {};
|
|
36
|
-
elementList.forEach(function (element, i) {
|
|
18
|
+
const indexList = Array(elementList.length)
|
|
19
|
+
.fill(0)
|
|
20
|
+
.map((_, ind) => ind);
|
|
21
|
+
this.set = Array.from(new Set(elementList));
|
|
22
|
+
const indexesOfSameElements = {};
|
|
23
|
+
elementList.forEach((element, i) => {
|
|
37
24
|
indexesOfSameElements[i] = [];
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
// // indexesOfSameElements[i] = [i]; // To make an illusion such that zero is different than zero, to make it possible to be consecutive
|
|
41
|
-
// return;
|
|
42
|
-
// }
|
|
43
|
-
elementList.forEach(function (innerElement, j) {
|
|
44
|
-
if (element == innerElement) {
|
|
25
|
+
elementList.forEach((el, j) => {
|
|
26
|
+
if (element === el) {
|
|
45
27
|
indexesOfSameElements[i].push(j);
|
|
46
28
|
}
|
|
47
29
|
});
|
|
48
30
|
});
|
|
49
|
-
// Can be uncomment, since it will increase the permutation number but it should be remain for exact results
|
|
50
31
|
this.extendIndexesOfSameElements(this.choicesByIndex, indexesOfSameElements);
|
|
51
|
-
// not make for choicesByIndex list so that options be little
|
|
52
32
|
this.extendIndexesOfSameElements(this.nonChoicesByIndex, indexesOfSameElements);
|
|
53
|
-
var choicesByIndexInSetFiltered = Object.keys(this.choicesByIndexInSet).filter(function (x) { return elementsIndexRel.indexOf(Number(x)) >= 0; })
|
|
54
|
-
.map(function (x) { return _this.choicesByIndexInSet[x]; });
|
|
55
|
-
// Same like above
|
|
56
|
-
// for(let i = 0; i < this.elementsIndexRel.length; i++) {
|
|
57
|
-
// choicesByIndexInSetFiltered[i] = this.choicesByIndexInSet[elementsIndexRel[i]]
|
|
58
|
-
// }
|
|
59
|
-
this.permutationGenOfSet = new PermutationGeneratorForSet_1.PermutationGeneratorForSet(elementList, indexList, choicesByIndexInSetFiltered, indexesOfSameElements, elementsOrderAbs, passFunction, randomizechoices);
|
|
60
|
-
}
|
|
61
|
-
// collect indexes of same elements into nonChoicesByIndex array, eg, slot1 should be placed by person 1 whose indexes are 3,4,5
|
|
62
|
-
CustomPermutationGenerator.prototype.extendIndexesOfSameElements = function (choicesByIndex, indexesOfSameElements) {
|
|
63
|
-
if (!choicesByIndex) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
var choicesIndexKeys = Object.keys(choicesByIndex);
|
|
67
|
-
for (var i = 0; i < choicesIndexKeys.length; i++) {
|
|
68
|
-
var key = choicesIndexKeys[i];
|
|
69
|
-
if (choicesByIndex[key]) {
|
|
70
|
-
for (var j = 0; j < choicesByIndex[key].length; j++) {
|
|
71
|
-
var ar = choicesByIndex[key].slice();
|
|
72
|
-
// debugger
|
|
73
|
-
if ((indexesOfSameElements[choicesByIndex[key][j]] || []).indexOf(choicesByIndex[key][j]) >= 0) {
|
|
74
|
-
ar = ar.concat(indexesOfSameElements[choicesByIndex[key][j]]);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
choicesByIndex[key] = ar ? ar.filter(function (el, i) { return ar.indexOf(el) == i; }) : [];
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
// ? Need indexes to make a set, since element list may not be distinct
|
|
82
|
-
CustomPermutationGenerator.prototype.init = function () {
|
|
83
33
|
if (this.nonChoicesByIndex) {
|
|
84
|
-
this.removeNonChoicesIndexes();
|
|
34
|
+
this.removeNonChoicesIndexes();
|
|
85
35
|
}
|
|
86
36
|
if (this.choicesByIndex) {
|
|
87
|
-
this.setChoicesIndexesInSet();
|
|
37
|
+
this.setChoicesIndexesInSet();
|
|
88
38
|
}
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
var _this = this;
|
|
102
|
-
Object.keys(this.choicesByIndex).forEach(function (key) {
|
|
103
|
-
if (!_this.choicesByIndex[key])
|
|
104
|
-
return; //?? bu gives error
|
|
105
|
-
var indexesInList = [];
|
|
106
|
-
for (var j = 0; j < _this.choicesByIndex[key].length; j++) {
|
|
107
|
-
indexesInList = indexesInList.concat(_this.getAllIndexesOfElementInList(String(_this.choicesByIndex[key][j]), _this.elementList));
|
|
39
|
+
this.completeRestOfIndexes();
|
|
40
|
+
this.permutationGenOfSet = new PermutationGeneratorForSet_1.PermutationGeneratorForSet(elementList, indexList, this.finalChoicesByIndexInSet, indexesOfSameElements, this.elementsOrderAbsolute, passFunction);
|
|
41
|
+
}
|
|
42
|
+
removeNonChoicesIndexes() {
|
|
43
|
+
const allIndexes = Array(this.elementList.length)
|
|
44
|
+
.fill(0)
|
|
45
|
+
.map((x, i) => i);
|
|
46
|
+
Object.keys(this.nonChoicesByIndex).forEach((key) => {
|
|
47
|
+
let indexes = allIndexes.slice();
|
|
48
|
+
for (const el of this.nonChoicesByIndex[key]) {
|
|
49
|
+
const indexesToRemove = this.getAllIndexesOfElementInList(el, this.elementList);
|
|
50
|
+
indexes = indexes.filter((x) => indexesToRemove.indexOf(x) < 0);
|
|
108
51
|
}
|
|
109
|
-
|
|
52
|
+
this.finalChoicesByIndexInSet[key] = indexes;
|
|
110
53
|
});
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
var indexes = allIndexes.slice();
|
|
117
|
-
for (var j = 0; j < _this.nonChoicesByIndex[key].length; j++) {
|
|
118
|
-
var indexesToRemove = _this.getAllIndexesOfElementInList(_this.nonChoicesByIndex[key][j], _this.elementList);
|
|
119
|
-
indexes = indexes.filter(function (x) { return indexesToRemove.indexOf(x) < 0; });
|
|
54
|
+
}
|
|
55
|
+
setChoicesIndexesInSet() {
|
|
56
|
+
for (const key in this.choicesByIndex) {
|
|
57
|
+
if (!this.choicesByIndex[key]) {
|
|
58
|
+
continue;
|
|
120
59
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
60
|
+
let indexesInList = [];
|
|
61
|
+
for (const el of this.choicesByIndex[key]) {
|
|
62
|
+
indexesInList = indexesInList.concat(this.getAllIndexesOfElementInList(el, this.elementList));
|
|
63
|
+
}
|
|
64
|
+
this.finalChoicesByIndexInSet[key] = indexesInList;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
getAllIndexesOfElementInList(el, list) {
|
|
68
|
+
const indexes = [];
|
|
69
|
+
for (let i = 0; i < list.length; i++) {
|
|
70
|
+
if (String(el) === String(list[i])) {
|
|
130
71
|
indexes.push(i);
|
|
131
72
|
}
|
|
132
73
|
}
|
|
133
74
|
return indexes;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
75
|
+
}
|
|
76
|
+
completeRestOfIndexes() {
|
|
77
|
+
const allIndexes = Array(this.elementList.length)
|
|
78
|
+
.fill(0)
|
|
79
|
+
.map((x, i) => i);
|
|
80
|
+
for (let i = 0; i < this.elementList.length; i++) {
|
|
81
|
+
if (!this.finalChoicesByIndexInSet[i]) {
|
|
82
|
+
this.finalChoicesByIndexInSet[i] = allIndexes.slice();
|
|
83
|
+
}
|
|
138
84
|
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
85
|
+
}
|
|
86
|
+
extendIndexesOfSameElements(choicesByIndex, indexesOfSameElements) {
|
|
87
|
+
if (!choicesByIndex) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
for (const key in choicesByIndex) {
|
|
91
|
+
if (choicesByIndex[key]) {
|
|
92
|
+
let clone;
|
|
93
|
+
for (const anotherKey of choicesByIndex[key]) {
|
|
94
|
+
clone = choicesByIndex[key].slice();
|
|
95
|
+
if ((indexesOfSameElements[anotherKey] || []).indexOf(anotherKey) >= 0) {
|
|
96
|
+
clone = clone.concat(indexesOfSameElements[anotherKey]);
|
|
97
|
+
}
|
|
150
98
|
}
|
|
151
|
-
|
|
152
|
-
else if (nextDistinct && nextDistinct.done) {
|
|
153
|
-
return null; // PermResultTypeEnum.ENDOFPERMUTATION;
|
|
99
|
+
choicesByIndex[key] = clone ? clone.filter((el, idx) => clone.indexOf(el) === idx) : [];
|
|
154
100
|
}
|
|
155
101
|
}
|
|
156
|
-
}
|
|
157
|
-
|
|
102
|
+
}
|
|
103
|
+
prev() {
|
|
104
|
+
if (this.cursor > 1) {
|
|
105
|
+
// cursor-1 is current, cursor-2 is prev
|
|
106
|
+
return this.history[--this.cursor - 1];
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
next() {
|
|
110
|
+
let nextDistinctPerm = this.nextDistinct();
|
|
111
|
+
return !nextDistinctPerm.done ? nextDistinctPerm.value : null;
|
|
112
|
+
}
|
|
113
|
+
nextDistinct() {
|
|
158
114
|
if (this.cursor < this.history.length) {
|
|
159
115
|
return { value: this.history[this.cursor++], done: false };
|
|
160
116
|
}
|
|
161
|
-
|
|
117
|
+
const nextPerm = this.permutationGenOfSet.next();
|
|
162
118
|
this.nextIndexList = nextPerm.value;
|
|
163
|
-
|
|
119
|
+
let elList;
|
|
164
120
|
if (this.nextIndexList && this.nextIndexList.length > 0) {
|
|
165
121
|
elList = this.getElementListByInitialListIndexes(nextPerm.value);
|
|
166
|
-
|
|
122
|
+
const hash = this.getHash(elList);
|
|
167
123
|
if (this.historyHashes.indexOf(hash) < 0 && (!this.passFunction || this.passFunction(elList))) {
|
|
168
124
|
this.current = elList;
|
|
169
125
|
this.history.push(elList);
|
|
@@ -171,70 +127,60 @@ var CustomPermutationGenerator = /** @class */ (function () {
|
|
|
171
127
|
this.cursor++;
|
|
172
128
|
}
|
|
173
129
|
else {
|
|
174
|
-
return
|
|
130
|
+
return this.nextDistinct();
|
|
175
131
|
}
|
|
176
132
|
}
|
|
177
133
|
return { done: nextPerm.done, value: elList };
|
|
178
|
-
}
|
|
179
|
-
|
|
134
|
+
}
|
|
135
|
+
saveCurrentToHistory() {
|
|
180
136
|
this.history.push(this.current);
|
|
181
|
-
|
|
137
|
+
const hash = this.getHash(this.current);
|
|
182
138
|
this.historyHashes.push(hash);
|
|
183
139
|
this.cursor++;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
for (
|
|
188
|
-
for (
|
|
140
|
+
}
|
|
141
|
+
getHash(elList) {
|
|
142
|
+
let hash = '';
|
|
143
|
+
for (let i = 0; i < elList.length; i++) {
|
|
144
|
+
for (let j = 0; j < i + 1; j++) {
|
|
189
145
|
hash += String(elList[i]);
|
|
190
146
|
}
|
|
191
147
|
}
|
|
192
148
|
return hash;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
var _this = this;
|
|
149
|
+
}
|
|
150
|
+
getElementListByInitialListIndexes(indexes) {
|
|
196
151
|
if (!indexes || !indexes.length) {
|
|
197
152
|
return [];
|
|
198
153
|
}
|
|
199
|
-
|
|
200
|
-
indexes.forEach(
|
|
154
|
+
const elList = [];
|
|
155
|
+
indexes.forEach((index) => {
|
|
201
156
|
// if(this.elementList[index]) // Can be added, but costly
|
|
202
157
|
{
|
|
203
|
-
elList.push(
|
|
158
|
+
elList.push(this.elementList[index]);
|
|
204
159
|
}
|
|
205
160
|
});
|
|
206
161
|
return elList;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
for (var i = 1; i < list.length; i++) {
|
|
210
|
-
if (list[i] == list[i - 1]) {
|
|
211
|
-
return false;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
return true;
|
|
215
|
-
};
|
|
216
|
-
CustomPermutationGenerator.prototype.reset = function () {
|
|
162
|
+
}
|
|
163
|
+
reset() {
|
|
217
164
|
this.cursor = 0;
|
|
218
|
-
}
|
|
219
|
-
|
|
165
|
+
}
|
|
166
|
+
getSet() {
|
|
220
167
|
return this.set || [];
|
|
221
|
-
}
|
|
222
|
-
|
|
168
|
+
}
|
|
169
|
+
isEmpty() {
|
|
223
170
|
return !this.set || this.set.length === 0;
|
|
224
|
-
}
|
|
225
|
-
|
|
171
|
+
}
|
|
172
|
+
getCurrent() {
|
|
226
173
|
if (this.cursor < this.history.length && this.cursor >= 0) {
|
|
227
174
|
return this.history[this.cursor];
|
|
228
175
|
}
|
|
229
176
|
else {
|
|
230
177
|
return null;
|
|
231
178
|
}
|
|
232
|
-
}
|
|
233
|
-
|
|
179
|
+
}
|
|
180
|
+
last() {
|
|
234
181
|
this.cursor = this.history.length - 1;
|
|
235
182
|
return this.history[this.cursor];
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
}());
|
|
183
|
+
}
|
|
184
|
+
}
|
|
239
185
|
exports.CustomPermutationGenerator = CustomPermutationGenerator;
|
|
240
186
|
//# sourceMappingURL=CustomPermutationGenerator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPermutationGenerator.js","sourceRoot":"","sources":["../src/CustomPermutationGenerator.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"CustomPermutationGenerator.js","sourceRoot":"","sources":["../src/CustomPermutationGenerator.ts"],"names":[],"mappings":";;;AAAA,6EAA0E;AAE1E,MAAa,0BAA0B;IAUrC,YACU,WAAkB,EAClB,iBAAyB,EAAE,EAC3B,oBAA4B,EAAE,EAC9B,qBAA6B,EAC7B,YAAwC;QAJxC,gBAAW,GAAX,WAAW,CAAO;QAClB,mBAAc,GAAd,cAAc,CAAa;QAC3B,sBAAiB,GAAjB,iBAAiB,CAAa;QAC9B,0BAAqB,GAArB,qBAAqB,CAAQ;QAC7B,iBAAY,GAAZ,YAAY,CAA4B;QAZlD,kBAAa,GAAa,EAAE,CAAC;QAC7B,6BAAwB,GAAG,EAAE,CAAC;QAC9B,YAAO,GAAU,EAAE,CAAC;QACpB,kBAAa,GAAU,EAAE,CAAC;QAC1B,YAAO,GAAU,EAAE,CAAC;QACpB,WAAM,GAAG,CAAC,CAAC;QAST,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC;aACxC,IAAI,CAAC,CAAC,CAAC;aACP,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QACxB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;QAE5C,MAAM,qBAAqB,GAAG,EAAE,CAAC;QAEjC,WAAW,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,EAAE;YACjC,qBAAqB,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;YAE9B,WAAW,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC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,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC;IAC5C,CAAC;IAED,UAAU;QACR,IAAI,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE;YACzD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SAClC;aAAM;YACL,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAED,IAAI;QACF,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;QAEtC,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;CACF;AAlOD,gEAkOC"}
|
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
export declare class PermutationGeneratorForSet {
|
|
2
2
|
private elementList;
|
|
3
|
-
private
|
|
3
|
+
private indexList;
|
|
4
4
|
private choicesByIndex?;
|
|
5
5
|
private indexesOfSameElements?;
|
|
6
6
|
private actualOrderOfElements?;
|
|
7
7
|
private passFunction?;
|
|
8
|
-
private randomizeChoices?;
|
|
9
8
|
choicesArraysInitial: any[];
|
|
10
9
|
choicesArrays: any[];
|
|
11
|
-
|
|
10
|
+
size: number;
|
|
12
11
|
currentIndsOfChoices: any[];
|
|
13
12
|
currentElInd: number;
|
|
14
13
|
newPerm: any[];
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
constructor(elementList: any[], set: any[], // set of index
|
|
22
|
-
choicesByIndex?: object, indexesOfSameElements?: any, actualOrderOfElements?: any[], passFunction?: Function, randomizeChoices?: boolean);
|
|
23
|
-
initPrevIndexes(): void;
|
|
24
|
-
isNewPermWithNewElementConsecutivelyDifferent(currentEl: any, elIndInChoices: any, elIndInPerm: any): any;
|
|
25
|
-
isNewPermWithNewElementConsecutivelyDifferent_(currentEl: any, elIndInChoices: any, elIndInPerm: any): any;
|
|
26
|
-
isPreviousElementDifferentOrCanSkipThisFn(currentEl: any, elIndInChoices: any, elIndInPerm: any): boolean;
|
|
14
|
+
initialIndexList: any[];
|
|
15
|
+
indexesAndChoicesCountsSortedByLength: any;
|
|
16
|
+
indexesAndChoicesCounts: any[];
|
|
17
|
+
visitedDict: {};
|
|
18
|
+
constructor(elementList: any[], indexList: any[], choicesByIndex?: object, indexesOfSameElements?: any, actualOrderOfElements?: any[], passFunction?: (items: any[]) => boolean);
|
|
19
|
+
isNewPermutationPassingFunction(currentEl: any, elIndInPerm: any): boolean;
|
|
27
20
|
reorderListAndChoicesAccordingToChoicesCount(): void;
|
|
28
|
-
revertResultPermToInitialOrder(newPerm: any): any[];
|
|
29
21
|
initChoicesArray(): void;
|
|
30
22
|
init(): void;
|
|
31
23
|
next(): {
|
|
@@ -36,7 +28,8 @@ export declare class PermutationGeneratorForSet {
|
|
|
36
28
|
value: any[];
|
|
37
29
|
};
|
|
38
30
|
getNextPerm(): any[];
|
|
39
|
-
goBack(newPerm: any,
|
|
31
|
+
goBack(newPerm: any, choicesArrayWithIndexes: any, selectedIndexesForPerm: any, elInd: any): any;
|
|
40
32
|
getAndSetPossibleNextElementForNewPerm(newPerm: any, choices: any, currentIndsInChoices: any, elInd: any): any;
|
|
41
33
|
validateParameters(elementSet: any, choicesByIndex: any): boolean;
|
|
34
|
+
revertResultPermToInitialOrder(newPerm: any): any[];
|
|
42
35
|
}
|