Skip to content

Commit aa21008

Browse files
✨ feat(minima): Export clarkson as minima.
1 parent 54cd119 commit aa21008

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ See [docs](https://aureooms.github.io/js-poset).
88
Parent is [@aureooms/js-algorithms](https://github.com/aureooms/js-algorithms).
99

1010
```js
11-
import {clarkson} from '@aureooms/js-poset';
11+
import {minima} from '@aureooms/js-poset';
1212
import {increasing} from '@aureooms/js-compare';
1313

1414
const a = [4, 12, 2, 6, 3];
1515

1616
const divides = (a, b) => b % a === 0;
17-
const n = clarkson(divides, a, 0, a.length); // 2
17+
const n = minima(divides, a, 0, a.length); // 2
1818
a.slice(0, n).sort(increasing); // 2 3
1919

2020
const norel = (_a, _b) => false;
21-
clarkson(norel, a, 0, a.length); // a.length
21+
minima(norel, a, 0, a.length); // a.length
2222
```
2323

2424
[![License](https://img.shields.io/github/license/aureooms/js-poset.svg)](https://raw.githubusercontent.com/aureooms/js-poset/master/LICENSE)

src/index.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
export * from './minima';
1+
import minima from './minima';
2+
3+
/* eslint import/no-anonymous-default-export: [2, {"allowObject": true}] */
4+
export default {
5+
minima
6+
};
7+
8+
export {minima};

src/minima/clarkson.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* -------------------- Kenneth L. Clarkson -
2323
*/
2424

25-
export function clarkson(prec, a, i, j) {
25+
export default function clarkson(prec, a, i, j) {
2626
//
2727
// This algorithm reorganizes the input array `a` as follows
2828
// - elements that are minima are put at the front of `a`

src/minima/index.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
export * from './clarkson';
1+
import clarkson from './clarkson';
2+
3+
export default clarkson;
4+
5+
export {clarkson};

test/src/minima.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import test from 'ava';
22

3-
import {clarkson} from '../../src';
3+
import {minima} from '../../src';
44

55
import {sort} from '@aureooms/js-insertion-sort';
66
import {alloc, iota} from '@aureooms/js-array';
@@ -15,7 +15,7 @@ test('minima 1', (t) => {
1515

1616
shuffle(a, 0, a.length);
1717

18-
const min = clarkson(divides, a, 0, a.length);
18+
const min = minima(divides, a, 0, a.length);
1919

2020
t.is(min, 1, 'minima set has cardinality 1');
2121

@@ -31,7 +31,7 @@ test('minima 2,3', (t) => {
3131

3232
shuffle(a, i, j);
3333

34-
const min = clarkson(divides, a, i, j);
34+
const min = minima(divides, a, i, j);
3535

3636
t.is(min - i, 2, 'minima set has cardinality 2');
3737

@@ -50,7 +50,7 @@ test('minima totally unordered set', (t) => {
5050

5151
shuffle(a, 0, n);
5252

53-
const min = clarkson(norel, a, 0, n);
53+
const min = minima(norel, a, 0, n);
5454

5555
t.deepEqual(min, n, 'minima set has cardinality n');
5656
});

0 commit comments

Comments
 (0)