28 #ifndef V8_SPLAY_TREE_INL_H_
29 #define V8_SPLAY_TREE_INL_H_
37 template<
typename Config,
class Allocator>
40 ForEachNode(&deleter);
44 template<
typename Config,
class Allocator>
49 root_ =
new(allocator_)
Node(key, Config::NoValue());
61 Node* node =
new(allocator_)
Node(key, Config::NoValue());
62 InsertInternal(cmp, node);
69 template<
typename Config,
class Allocator>
73 node->right_ = root_->right_;
77 node->left_ = root_->left_;
84 template<
typename Config,
class Allocator>
85 bool SplayTree<Config, Allocator>::FindInternal(
const Key& key) {
93 template<
typename Config,
class Allocator>
95 return FindInternal(key);
99 template<
typename Config,
class Allocator>
101 if (FindInternal(key)) {
102 locator->bind(root_);
110 template<
typename Config,
class Allocator>
122 locator->bind(root_);
126 root_ = root_->left_;
127 bool result = FindGreatest(locator);
134 template<
typename Config,
class Allocator>
146 locator->bind(root_);
150 root_ = root_->right_;
151 bool result = FindLeast(locator);
158 template<
typename Config,
class Allocator>
162 Node* current = root_;
163 while (current->right_ !=
NULL)
164 current = current->right_;
165 locator->bind(current);
170 template<
typename Config,
class Allocator>
174 Node* current = root_;
175 while (current->left_ !=
NULL)
176 current = current->left_;
177 locator->bind(current);
182 template<
typename Config,
class Allocator>
184 const Key& new_key) {
185 if (!FindInternal(old_key))
187 Node* node_to_move = root_;
188 RemoveRootNode(old_key);
196 node_to_move->key_ = new_key;
197 InsertInternal(cmp, node_to_move);
202 template<
typename Config,
class Allocator>
204 if (!FindInternal(key))
206 Node* node_to_remove = root_;
208 delete node_to_remove;
213 template<
typename Config,
class Allocator>
215 if (root_->left_ ==
NULL) {
217 root_ = root_->right_;
220 Node* right = root_->right_;
222 root_ = root_->left_;
227 root_->right_ = right;
232 template<
typename Config,
class Allocator>
236 Node dummy_node(Config::kNoKey, Config::NoValue());
242 Node* dummy = &dummy_node;
245 Node* current = root_;
249 if (current->left_ ==
NULL)
253 Node* temp = current->left_;
254 current->left_ = temp->right_;
255 temp->right_ = current;
257 if (current->left_ ==
NULL)
261 right->left_ = current;
263 current = current->left_;
264 }
else if (cmp > 0) {
265 if (current->right_ ==
NULL)
269 Node* temp = current->right_;
270 current->right_ = temp->left_;
271 temp->left_ = current;
273 if (current->right_ ==
NULL)
277 left->right_ = current;
279 current = current->right_;
285 left->right_ = current->left_;
286 right->left_ = current->right_;
287 current->left_ = dummy->right_;
288 current->right_ = dummy->left_;
293 template <
typename Config,
class Allocator>
template <
class Callback>
295 NodeToPairAdaptor<Callback> callback_adaptor(callback);
296 ForEachNode(&callback_adaptor);
300 template <
typename Config,
class Allocator>
template <
class Callback>
302 if (root_ ==
NULL)
return;
305 nodes_to_visit.Add(root_, allocator_);
307 while (pos < nodes_to_visit.length()) {
308 Node* node = nodes_to_visit[pos++];
309 if (node->left() !=
NULL) nodes_to_visit.Add(node->left(), allocator_);
310 if (node->right() !=
NULL) nodes_to_visit.Add(node->right(), allocator_);
311 callback->Call(node);
318 #endif // V8_SPLAY_TREE_INL_H_
enable upcoming ES6 features enable harmony block scoping enable harmony enable harmony proxies enable harmony generators enable harmony numeric enable harmony string enable harmony math functions harmony_scoping harmony_symbols harmony_collections harmony_iteration harmony_strings harmony_scoping harmony_maths tracks arrays with only smi values Optimize object Array DOM strings and string pretenure call new trace pretenuring decisions of HAllocate instructions track fields with only smi values track fields with heap values track_fields track_fields Enables optimizations which favor memory size over execution speed use string slices optimization filter maximum number of GVN fix point iterations use function inlining use allocation folding eliminate write barriers targeting allocations in optimized code maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining crankshaft harvests type feedback from stub cache trace check elimination phase hydrogen tracing filter NULL
bool Find(const Key &key, Locator *locator)
bool Insert(const Key &key, Locator *locator)
bool FindGreatest(Locator *locator)
void Splay(const Key &key)
bool Contains(const Key &key)
void ForEach(Callback *callback)
int Compare(const T &a, const T &b)
bool FindLeast(Locator *locator)
bool Move(const Key &old_key, const Key &new_key)
bool FindLeastGreaterThan(const Key &key, Locator *locator)
bool Remove(const Key &key)
bool FindGreatestLessThan(const Key &key, Locator *locator)