@slimlib/refine-partition 1.0.0 → 1.0.2
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 +4 -2
- package/dist/index.cjs +35 -35
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +35 -35
- package/package.json +20 -42
package/README.md
CHANGED
|
@@ -6,11 +6,13 @@ https://en.wikipedia.org/wiki/Partition_refinement
|
|
|
6
6
|
|
|
7
7
|
> To perform a refinement operation, the algorithm loops through the elements of the given set X. For each such element x, it finds the set Si that contains x, and checks whether a second set for Si ∩ X has already been started. If not, it creates the second set and adds Si to a list L of the sets that are split by the operation. Then, regardless of whether a new set was formed, the algorithm removes x from Si and adds it to Si ∩ X. In the representation in which all elements are stored in a single array, moving x from one set to another may be performed by swapping x with the final element of Si and then decrementing the end index of Si and the start index of the new set. Finally, after all elements of X have been processed in this way, the algorithm loops through L, separating each current set Si from the second set that has been split from it, and reports both of these sets as being newly formed by the refinement operation.
|
|
8
8
|
|
|
9
|
+
[Changelog](./CHANGELOG.md)
|
|
10
|
+
|
|
9
11
|
## API
|
|
10
12
|
|
|
11
13
|
### `<T>() => (newPartitionCandidate?: Iterable<T>) => Iterable<Iterable<T>>`
|
|
12
14
|
|
|
13
|
-
|
|
15
|
+
Creates a refiner function.
|
|
14
16
|
|
|
15
17
|
Pass to it new candidates for refinement.
|
|
16
18
|
|
|
@@ -29,4 +31,4 @@ console.log(refineNext()); // Iterable of Iterables: ((a), (b, c), (e))
|
|
|
29
31
|
|
|
30
32
|
# License
|
|
31
33
|
|
|
32
|
-
[MIT](
|
|
34
|
+
[MIT](https://github.com/kshutkin/slimlib/blob/main/LICENSE)
|
package/dist/index.cjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
function index () {
|
|
4
|
-
const processed = new Set();
|
|
5
|
-
return (newPartitionCandidate) => {
|
|
6
|
-
if (newPartitionCandidate) {
|
|
7
|
-
const intersections = new Map();
|
|
8
|
-
for (const element of newPartitionCandidate) {
|
|
9
|
-
for (const partitionItem of processed) {
|
|
10
|
-
if (partitionItem.has(element)) {
|
|
11
|
-
let intersection = intersections.get(partitionItem);
|
|
12
|
-
if (intersection === undefined) {
|
|
13
|
-
intersection = new Set();
|
|
14
|
-
intersections.set(partitionItem, intersection);
|
|
15
|
-
}
|
|
16
|
-
intersection.add(element);
|
|
17
|
-
partitionItem.delete(element);
|
|
18
|
-
if (partitionItem.size === 0) {
|
|
19
|
-
processed.delete(partitionItem);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
const newPartitionItem = new Set(newPartitionCandidate);
|
|
25
|
-
for (const intersection of intersections.values()) {
|
|
26
|
-
processed.add(intersection);
|
|
27
|
-
for (const element of intersection) {
|
|
28
|
-
newPartitionItem.delete(element);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
intersections.clear();
|
|
32
|
-
if (newPartitionItem.size > 0) {
|
|
33
|
-
processed.add(newPartitionItem);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return processed;
|
|
37
|
-
};
|
|
3
|
+
function index () {
|
|
4
|
+
const processed = new Set();
|
|
5
|
+
return (newPartitionCandidate) => {
|
|
6
|
+
if (newPartitionCandidate) {
|
|
7
|
+
const intersections = new Map();
|
|
8
|
+
for (const element of newPartitionCandidate) {
|
|
9
|
+
for (const partitionItem of processed) {
|
|
10
|
+
if (partitionItem.has(element)) {
|
|
11
|
+
let intersection = intersections.get(partitionItem);
|
|
12
|
+
if (intersection === undefined) {
|
|
13
|
+
intersection = new Set();
|
|
14
|
+
intersections.set(partitionItem, intersection);
|
|
15
|
+
}
|
|
16
|
+
intersection.add(element);
|
|
17
|
+
partitionItem.delete(element);
|
|
18
|
+
if (partitionItem.size === 0) {
|
|
19
|
+
processed.delete(partitionItem);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const newPartitionItem = new Set(newPartitionCandidate);
|
|
25
|
+
for (const intersection of intersections.values()) {
|
|
26
|
+
processed.add(intersection);
|
|
27
|
+
for (const element of intersection) {
|
|
28
|
+
newPartitionItem.delete(element);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
intersections.clear();
|
|
32
|
+
if (newPartitionItem.size > 0) {
|
|
33
|
+
processed.add(newPartitionItem);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return processed;
|
|
37
|
+
};
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
module.exports = index;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default function <T>(): (newPartitionCandidate?: Iterable<T>
|
|
1
|
+
export default function <T>(): (newPartitionCandidate?: Iterable<T>) => Iterable<Iterable<T>>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
function index () {
|
|
2
|
-
const processed = new Set();
|
|
3
|
-
return (newPartitionCandidate) => {
|
|
4
|
-
if (newPartitionCandidate) {
|
|
5
|
-
const intersections = new Map();
|
|
6
|
-
for (const element of newPartitionCandidate) {
|
|
7
|
-
for (const partitionItem of processed) {
|
|
8
|
-
if (partitionItem.has(element)) {
|
|
9
|
-
let intersection = intersections.get(partitionItem);
|
|
10
|
-
if (intersection === undefined) {
|
|
11
|
-
intersection = new Set();
|
|
12
|
-
intersections.set(partitionItem, intersection);
|
|
13
|
-
}
|
|
14
|
-
intersection.add(element);
|
|
15
|
-
partitionItem.delete(element);
|
|
16
|
-
if (partitionItem.size === 0) {
|
|
17
|
-
processed.delete(partitionItem);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
const newPartitionItem = new Set(newPartitionCandidate);
|
|
23
|
-
for (const intersection of intersections.values()) {
|
|
24
|
-
processed.add(intersection);
|
|
25
|
-
for (const element of intersection) {
|
|
26
|
-
newPartitionItem.delete(element);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
intersections.clear();
|
|
30
|
-
if (newPartitionItem.size > 0) {
|
|
31
|
-
processed.add(newPartitionItem);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return processed;
|
|
35
|
-
};
|
|
1
|
+
function index () {
|
|
2
|
+
const processed = new Set();
|
|
3
|
+
return (newPartitionCandidate) => {
|
|
4
|
+
if (newPartitionCandidate) {
|
|
5
|
+
const intersections = new Map();
|
|
6
|
+
for (const element of newPartitionCandidate) {
|
|
7
|
+
for (const partitionItem of processed) {
|
|
8
|
+
if (partitionItem.has(element)) {
|
|
9
|
+
let intersection = intersections.get(partitionItem);
|
|
10
|
+
if (intersection === undefined) {
|
|
11
|
+
intersection = new Set();
|
|
12
|
+
intersections.set(partitionItem, intersection);
|
|
13
|
+
}
|
|
14
|
+
intersection.add(element);
|
|
15
|
+
partitionItem.delete(element);
|
|
16
|
+
if (partitionItem.size === 0) {
|
|
17
|
+
processed.delete(partitionItem);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const newPartitionItem = new Set(newPartitionCandidate);
|
|
23
|
+
for (const intersection of intersections.values()) {
|
|
24
|
+
processed.add(intersection);
|
|
25
|
+
for (const element of intersection) {
|
|
26
|
+
newPartitionItem.delete(element);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
intersections.clear();
|
|
30
|
+
if (newPartitionItem.size > 0) {
|
|
31
|
+
processed.add(newPartitionItem);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return processed;
|
|
35
|
+
};
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
export { index as default };
|
package/package.json
CHANGED
|
@@ -1,65 +1,43 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
2
|
+
"type": "module",
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"name": "@slimlib/refine-partition",
|
|
5
|
+
"description": "Simple refine partition implementation",
|
|
6
|
+
"license": "MIT",
|
|
5
7
|
"author": "Konstantin Shutkin",
|
|
6
|
-
"
|
|
8
|
+
"main": "./dist/index.cjs",
|
|
9
|
+
"module": "./dist/index.mjs",
|
|
7
10
|
"exports": {
|
|
8
11
|
".": {
|
|
9
12
|
"require": "./dist/index.cjs",
|
|
10
13
|
"default": "./dist/index.mjs"
|
|
11
|
-
}
|
|
14
|
+
},
|
|
15
|
+
"./package.json": "./package.json"
|
|
12
16
|
},
|
|
13
|
-
"
|
|
14
|
-
"module": "./dist/index.mjs",
|
|
15
|
-
"typings": "./dist/index.d.ts",
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
16
18
|
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
"LICENSE"
|
|
19
|
+
"dist"
|
|
19
20
|
],
|
|
20
21
|
"engines": {
|
|
21
22
|
"node": ">=15"
|
|
22
23
|
},
|
|
23
24
|
"repository": {
|
|
24
25
|
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/kshutkin/slimlib.git"
|
|
26
|
-
|
|
27
|
-
"bugs": {
|
|
28
|
-
"url": "https://github.com/kshutkin/slimlib/issues"
|
|
26
|
+
"url": "git+https://github.com/kshutkin/slimlib.git",
|
|
27
|
+
"directory": "refine-partition"
|
|
29
28
|
},
|
|
29
|
+
"bugs": "https://github.com/kshutkin/slimlib/issues",
|
|
30
30
|
"homepage": "https://github.com/kshutkin/slimlib/blob/main/refine-partition/README.md",
|
|
31
31
|
"readme": "README.md",
|
|
32
|
-
"description": "Simple refine partition implementation",
|
|
33
32
|
"keywords": [
|
|
34
33
|
"@slimlib",
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
34
|
+
"refine",
|
|
35
|
+
"partition",
|
|
36
|
+
"refine partition"
|
|
38
37
|
],
|
|
39
38
|
"scripts": {
|
|
40
|
-
"build": "pkgbld",
|
|
39
|
+
"build": "pkgbld-internal",
|
|
41
40
|
"test": "jest --collectCoverage",
|
|
42
|
-
"lint": "eslint ./src"
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"@semantic-release/changelog": "6.0.1",
|
|
47
|
-
"@semantic-release/commit-analyzer": "9.0.2",
|
|
48
|
-
"@semantic-release/git": "10.0.1",
|
|
49
|
-
"@semantic-release/npm": "9.0.0",
|
|
50
|
-
"@semantic-release/release-notes-generator": "10.0.3",
|
|
51
|
-
"@types/jest": "27.4.0",
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "5.11.0",
|
|
53
|
-
"@typescript-eslint/parser": "5.11.0",
|
|
54
|
-
"conventional-changelog-angular": "5.0.13",
|
|
55
|
-
"eslint": "8.8.0",
|
|
56
|
-
"jest": "27.5.1",
|
|
57
|
-
"semantic-release": "19.0.2",
|
|
58
|
-
"semantic-release-monorepo": "7.0.5",
|
|
59
|
-
"ts-jest": "27.1.3",
|
|
60
|
-
"typescript": "4.5.x",
|
|
61
|
-
"update-monorepo-package-json": "0.2.0",
|
|
62
|
-
"pkgbld": "1.1.9"
|
|
63
|
-
},
|
|
64
|
-
"dependencies": {}
|
|
65
|
-
}
|
|
41
|
+
"lint": "eslint ./src"
|
|
42
|
+
}
|
|
43
|
+
}
|