Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: src/splay-tree-inl.h

Issue 19054006: Implement simple effect typing for variables (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/splay-tree.h ('k') | src/types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 template<typename Config, class Allocator> 84 template<typename Config, class Allocator>
85 bool SplayTree<Config, Allocator>::FindInternal(const Key& key) { 85 bool SplayTree<Config, Allocator>::FindInternal(const Key& key) {
86 if (is_empty()) 86 if (is_empty())
87 return false; 87 return false;
88 Splay(key); 88 Splay(key);
89 return Config::Compare(key, root_->key_) == 0; 89 return Config::Compare(key, root_->key_) == 0;
90 } 90 }
91 91
92 92
93 template<typename Config, class Allocator> 93 template<typename Config, class Allocator>
94 bool SplayTree<Config, Allocator>::Contains(const Key& key) {
95 return FindInternal(key);
96 }
97
98
99 template<typename Config, class Allocator>
94 bool SplayTree<Config, Allocator>::Find(const Key& key, Locator* locator) { 100 bool SplayTree<Config, Allocator>::Find(const Key& key, Locator* locator) {
95 if (FindInternal(key)) { 101 if (FindInternal(key)) {
96 locator->bind(root_); 102 locator->bind(root_);
97 return true; 103 return true;
98 } else { 104 } else {
99 return false; 105 return false;
100 } 106 }
101 } 107 }
102 108
103 109
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 292
287 template <typename Config, class Allocator> template <class Callback> 293 template <typename Config, class Allocator> template <class Callback>
288 void SplayTree<Config, Allocator>::ForEach(Callback* callback) { 294 void SplayTree<Config, Allocator>::ForEach(Callback* callback) {
289 NodeToPairAdaptor<Callback> callback_adaptor(callback); 295 NodeToPairAdaptor<Callback> callback_adaptor(callback);
290 ForEachNode(&callback_adaptor); 296 ForEachNode(&callback_adaptor);
291 } 297 }
292 298
293 299
294 template <typename Config, class Allocator> template <class Callback> 300 template <typename Config, class Allocator> template <class Callback>
295 void SplayTree<Config, Allocator>::ForEachNode(Callback* callback) { 301 void SplayTree<Config, Allocator>::ForEachNode(Callback* callback) {
302 if (root_ == NULL) return;
296 // Pre-allocate some space for tiny trees. 303 // Pre-allocate some space for tiny trees.
297 List<Node*, Allocator> nodes_to_visit(10, allocator_); 304 List<Node*, Allocator> nodes_to_visit(10, allocator_);
298 if (root_ != NULL) nodes_to_visit.Add(root_, allocator_); 305 nodes_to_visit.Add(root_, allocator_);
299 int pos = 0; 306 int pos = 0;
300 while (pos < nodes_to_visit.length()) { 307 while (pos < nodes_to_visit.length()) {
301 Node* node = nodes_to_visit[pos++]; 308 Node* node = nodes_to_visit[pos++];
302 if (node->left() != NULL) nodes_to_visit.Add(node->left(), allocator_); 309 if (node->left() != NULL) nodes_to_visit.Add(node->left(), allocator_);
303 if (node->right() != NULL) nodes_to_visit.Add(node->right(), allocator_); 310 if (node->right() != NULL) nodes_to_visit.Add(node->right(), allocator_);
304 callback->Call(node); 311 callback->Call(node);
305 } 312 }
306 } 313 }
307 314
308 315
309 } } // namespace v8::internal 316 } } // namespace v8::internal
310 317
311 #endif // V8_SPLAY_TREE_INL_H_ 318 #endif // V8_SPLAY_TREE_INL_H_
OLDNEW
« no previous file with comments | « src/splay-tree.h ('k') | src/types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698