Lines Matching refs:key
73 var key;
75 key = GenerateKey();
76 } while (splayTree.find(key) != null);
77 var payload = GeneratePayloadTree(kSplayTreePayloadDepth, String(key));
78 splayTree.insert(key, payload);
79 return key;
115 var key = InsertNewNode();
116 var greatest = splayTree.findGreatestLessThan(key);
117 if (greatest == null) splayTree.remove(key);
118 else splayTree.remove(greatest.key);
160 SplayTree.prototype.insert = function(key, value) { argument
162 this.root_ = new SplayTree.Node(key, value);
167 this.splay_(key);
168 if (this.root_.key == key) {
171 var node = new SplayTree.Node(key, value);
172 if (key > this.root_.key) {
193 SplayTree.prototype.remove = function(key) { argument
195 throw Error('Key not found: ' + key);
197 this.splay_(key);
198 if (this.root_.key != key) {
199 throw Error('Key not found: ' + key);
208 this.splay_(key);
224 SplayTree.prototype.find = function(key) { argument
228 this.splay_(key);
229 return this.root_.key == key ? this.root_ : null;
252 SplayTree.prototype.findGreatestLessThan = function(key) { argument
258 this.splay_(key);
261 if (this.root_.key < key) {
277 this.root_.traverse_(function(node) { result.push(node.key); });
293 SplayTree.prototype.splay_ = function(key) { argument
306 if (key < current.key) {
310 if (key < current.left.key) {
324 } else if (key > current.key) {
328 if (key > current.right.key) {
361 SplayTree.Node = function(key, value) { argument
362 this.key = key;