| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 --this._words[word]; | 61 --this._words[word]; |
| 62 }, | 62 }, |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * @param {string} prefix | 65 * @param {string} prefix |
| 66 * @return {!Array.<string>} | 66 * @return {!Array.<string>} |
| 67 */ | 67 */ |
| 68 wordsWithPrefix: function(prefix) | 68 wordsWithPrefix: function(prefix) |
| 69 { | 69 { |
| 70 var words = []; | 70 var words = []; |
| 71 for(var i in this._words) { | 71 for (var i in this._words) { |
| 72 if (i.startsWith(prefix)) | 72 if (i.startsWith(prefix)) |
| 73 words.push(i); | 73 words.push(i); |
| 74 } | 74 } |
| 75 return words; | 75 return words; |
| 76 }, | 76 }, |
| 77 | 77 |
| 78 /** | 78 /** |
| 79 * @param {string} word | 79 * @param {string} word |
| 80 * @return {boolean} | 80 * @return {boolean} |
| 81 */ | 81 */ |
| 82 hasWord: function(word) | 82 hasWord: function(word) |
| 83 { | 83 { |
| 84 return !!this._words[word]; | 84 return !!this._words[word]; |
| 85 }, | 85 }, |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * @param {string} word | 88 * @param {string} word |
| 89 * @return {number} | 89 * @return {number} |
| 90 */ | 90 */ |
| 91 wordCount: function(word) | 91 wordCount: function(word) |
| 92 { | 92 { |
| 93 return this._words[word] ? this._words[word] : 0; | 93 return this._words[word] ? this._words[word] : 0; |
| 94 }, | 94 }, |
| 95 | 95 |
| 96 reset: function() | 96 reset: function() |
| 97 { | 97 { |
| 98 this._words = {}; | 98 this._words = {}; |
| 99 } | 99 } |
| 100 } | 100 } |
| OLD | NEW |