Export StateMachine
This commit is contained in:
2 files changed
+4
-8
No files matched your search
@@ -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
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in new issue
Block a user