提交 e7b3d10f 编写于 作者: J Johannes Rieken

use Map in TrieMap

上级 60856fee
......@@ -299,9 +299,9 @@ export class LRUCache<T> extends BoundedLinkedMap<T> {
// --- trie'ish datastructure
interface Node<E> {
class Node<E> {
element?: E;
children: { [key: string]: Node<E> };
readonly children = new Map<string, E>();
}
/**
......@@ -313,7 +313,7 @@ export class TrieMap<E> {
static PathSplitter = s => s.split(/[\\/]/).filter(s => !!s);
private _splitter: (s: string) => string[];
private _root: Node<E> = { children: Object.create(null) };
private _root = new Node<E>();
constructor(splitter: (s: string) => string[]) {
this._splitter = splitter;
......@@ -337,7 +337,7 @@ export class TrieMap<E> {
// create new nodes
let newNode: Node<E>;
for (; i < parts.length; i++) {
newNode = { children: Object.create(null) };
newNode = new Node<E>();
node.children[parts[i]] = newNode;
node = newNode;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册