OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 return this.root_; | 184 return this.root_; |
185 } else if (this.root_.left) { | 185 } else if (this.root_.left) { |
186 return this.findMax(this.root_.left); | 186 return this.findMax(this.root_.left); |
187 } else { | 187 } else { |
188 return null; | 188 return null; |
189 } | 189 } |
190 }; | 190 }; |
191 | 191 |
192 | 192 |
193 /** | 193 /** |
| 194 * @return {Array<*>} An array containing all the values of tree's nodes paired |
| 195 * with keys. |
| 196 */ |
| 197 SplayTree.prototype.exportKeysAndValues = function() { |
| 198 var result = []; |
| 199 this.traverse_(function(node) { result.push([node.key, node.value]); }); |
| 200 return result; |
| 201 }; |
| 202 |
| 203 |
| 204 /** |
194 * @return {Array<*>} An array containing all the values of tree's nodes. | 205 * @return {Array<*>} An array containing all the values of tree's nodes. |
195 */ | 206 */ |
196 SplayTree.prototype.exportValues = function() { | 207 SplayTree.prototype.exportValues = function() { |
197 var result = []; | 208 var result = []; |
198 this.traverse_(function(node) { result.push(node.value); }); | 209 this.traverse_(function(node) { result.push(node.value); }); |
199 return result; | 210 return result; |
200 }; | 211 }; |
201 | 212 |
202 | 213 |
203 /** | 214 /** |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 /** | 318 /** |
308 * @type {SplayTree.Node} | 319 * @type {SplayTree.Node} |
309 */ | 320 */ |
310 SplayTree.Node.prototype.left = null; | 321 SplayTree.Node.prototype.left = null; |
311 | 322 |
312 | 323 |
313 /** | 324 /** |
314 * @type {SplayTree.Node} | 325 * @type {SplayTree.Node} |
315 */ | 326 */ |
316 SplayTree.Node.prototype.right = null; | 327 SplayTree.Node.prototype.right = null; |
OLD | NEW |