Skip to content

Commit 89cb233

Browse files
Removed FACreationOptions interface.
This also changes all free intersection functions.
1 parent b8616a6 commit 89cb233

2 files changed

Lines changed: 13 additions & 29 deletions

File tree

src/fa-types.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -164,18 +164,6 @@ export interface FABuilder<S, T> extends NodeFactory<S> {
164164
readonly linkNodes: (from: S, to: S, transition: T) => void;
165165
}
166166

167-
export interface FACreationOptions {
168-
/**
169-
* The maximum number of nodes the operation is allowed to create before throwing a `TooManyNodesError`.
170-
*
171-
* If the maximum number of nodes is unset or set to `Infinity`, the operation may create as many nodes as
172-
* necessary. This might cause the machine to run out of memory.
173-
*
174-
* @default 10000
175-
*/
176-
maxNodes?: number;
177-
}
178-
179167
/**
180168
* An {@link FAIterator} where transitions are map of states to character sets.
181169
*

src/intersection.ts

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { WordSet } from "./word-set";
33
import * as Iter from "./iter";
44
import { MapFABuilderNode } from "./iter";
55
import { MaxCharacterError } from "./errors";
6-
import { FACreationOptions, TransitionIterable, TransitionIterator } from "./fa-types";
6+
import { TransitionIterable, TransitionIterator } from "./fa-types";
77
import { wordSetsToWords } from "./words";
88

99
/**
@@ -13,20 +13,16 @@ import { wordSetsToWords } from "./words";
1313
*
1414
* @param left
1515
* @param right
16-
* @param options
16+
* @param maxNodes
1717
*/
1818
export function getIntersectionIterator<L, R>(
1919
left: TransitionIterable<L>,
2020
right: TransitionIterable<R>,
21-
options?: Readonly<FACreationOptions>
21+
maxNodes: number = 10_000
2222
): TransitionIterator<MapFABuilderNode> {
2323
MaxCharacterError.assert(left, right, "TransitionIterable");
2424

25-
return Iter.intersection(
26-
new Iter.MapFABuilder(options?.maxNodes ?? 10_000),
27-
left.transitionIterator(),
28-
right.transitionIterator()
29-
);
25+
return Iter.intersection(new Iter.MapFABuilder(maxNodes), left.transitionIterator(), right.transitionIterator());
3026
}
3127

3228
/**
@@ -41,14 +37,14 @@ export function getIntersectionIterator<L, R>(
4137
*
4238
* @param left
4339
* @param right
44-
* @param options
40+
* @param maxNodes
4541
*/
4642
export function isDisjointWith<L, R>(
4743
left: TransitionIterable<L>,
4844
right: TransitionIterable<R>,
49-
options?: Readonly<FACreationOptions>
45+
maxNodes: number = 10_000
5046
): boolean {
51-
const iter = getIntersectionIterator(left, right, options);
47+
const iter = getIntersectionIterator(left, right, maxNodes);
5248

5349
return !Iter.canReachFinal(Iter.mapOut(iter, n => n.keys()));
5450
}
@@ -65,14 +61,14 @@ export function isDisjointWith<L, R>(
6561
*
6662
* @param left
6763
* @param right
68-
* @param options
64+
* @param maxNodes
6965
*/
7066
export function getIntersectionWordSets<L, R>(
7167
left: TransitionIterable<L>,
7268
right: TransitionIterable<R>,
73-
options?: Readonly<FACreationOptions>
69+
maxNodes: number = 10_000
7470
): Iterable<WordSet> {
75-
const iter = getIntersectionIterator(left, right, options);
71+
const iter = getIntersectionIterator(left, right, maxNodes);
7672

7773
return Iter.iterateWordSets(iter);
7874
}
@@ -88,12 +84,12 @@ export function getIntersectionWordSets<L, R>(
8884
*
8985
* @param left
9086
* @param right
91-
* @param options
87+
* @param maxNodes
9288
*/
9389
export function getIntersectionWords<L, R>(
9490
left: TransitionIterable<L>,
9591
right: TransitionIterable<R>,
96-
options?: Readonly<FACreationOptions>
92+
maxNodes: number = 10_000
9793
): Iterable<Word> {
98-
return wordSetsToWords(getIntersectionWordSets(left, right, options));
94+
return wordSetsToWords(getIntersectionWordSets(left, right, maxNodes));
9995
}

0 commit comments

Comments
 (0)