This commit is contained in:
Mahdi Dibaiee
2015-07-26 14:07:07 +04:30
parent ca572e392e
commit 10fd1038fc
17 changed files with 423 additions and 232 deletions

View File

@@ -37,18 +37,16 @@ class Trie {
return parent;
}
all(search) {
let node = this.find(search);
findWords(value, parent = this.root) {
let top = this.find(value, parent);
if (!node) return null;
let words = [];
let all = [node];
node.children.forEach(function addToAll(child) {
all.push(child);
child.children.forEach(addToAll);
top.children.forEach(function getWords(node) {
if (node.category) words.push(node);
node.children.forEach(getWords);
});
return all;
return words;
}
}