Export StateMachine

This commit is contained in:
mindfulminun committed 2023-09-03 01:43:24 -05:00
1 parent b8e0fcb8d1
commit 6834c45ac1
2 files changed
+4 -8

No files matched your search

+2 -6
View File
@@ -28,17 +28,13 @@ export class BinaryHeap<T> implements Iterable<T> {
while (this.length !== 0) yield this.pop()!
}
/**
* Insert an element into the heap.
*/
/** Insert an element into the heap. */
push(element: T): void {
this.#elements.push(element)
this.#bubbleUp(this.length - 1)
}
/**
* Remove the minimum element from the heap and return it.
*/
/** Remove the minimum element from the heap and return it. */
pop(): T | undefined {
if (this.length === 0) return undefined
+2 -2
View File
@@ -1,10 +1,10 @@
type Transition<State extends string | number | symbol, InputAlphabet, Context> = (
export type Transition<State extends string | number | symbol, InputAlphabet, Context> = (
this: StateMachine<State, InputAlphabet, Context>,
input: InputAlphabet,
machine: StateMachine<State, InputAlphabet, Context>
) => void
class StateMachine<State extends string | number | symbol = 0, InputAlphabet = string, Context = null> {
export class StateMachine<State extends string | number | symbol = 0, InputAlphabet = string, Context = null> {
#initialState: State
#transitionTable: Partial<Record<State, Transition<State, InputAlphabet, Context>>>
#acceptStates: Set<State>