Add comments to Trie "add" method.

This commit is contained in:
Oleksii Trekhleb 2018-08-25 13:34:05 +03:00
parent eac3e81a21
commit 6e2ff9b604

View File

@ -30,6 +30,8 @@ export default class TrieNode {
} }
const childNode = this.children.get(character); const childNode = this.children.get(character);
// In cases similar to adding "car" after "carpet" we need to mark "r" character as complete.
childNode.isCompleteWord = childNode.isCompleteWord || isCompleteWord; childNode.isCompleteWord = childNode.isCompleteWord || isCompleteWord;
return childNode; return childNode;