This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class Trie { | |
private tree: any = {}; | |
public add(s: string): void { | |
let cur = this.tree; | |
for (const c of s) { | |
if (!cur[c]) cur[c] = { isString: false }; | |
cur = cur[c]; | |
} | |
cur.isString = true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Transition<State, Operation> = (state: State, operation: Operation) => State; | |
class Store<State, Operation> { | |
private initialState: State; | |
private operations: Operation[] = []; | |
private transition: Transition<State, Operation>; | |
private currentState: State; | |
constructor(initialState: State, transition: Transition<State, Operation>) { | |
this.initialState = initialState; |
OlderNewer