| Index: src/splay-tree-inl.h
|
| diff --git a/src/splay-tree-inl.h b/src/splay-tree-inl.h
|
| index 4640ed5b08bdda8509f01ba34ac1e2d788970b04..bb6ded7098b78d8f384e084e3d4adb88d9d6c7a7 100644
|
| --- a/src/splay-tree-inl.h
|
| +++ b/src/splay-tree-inl.h
|
| @@ -42,10 +42,12 @@ SplayTree<Config, Allocator>::~SplayTree() {
|
|
|
|
|
| template<typename Config, class Allocator>
|
| -bool SplayTree<Config, Allocator>::Insert(const Key& key, Locator* locator) {
|
| +bool SplayTree<Config, Allocator>::Insert(const Key& key,
|
| + Locator* locator,
|
| + Allocator allocator) {
|
| if (is_empty()) {
|
| // If the tree is empty, insert the new node.
|
| - root_ = new Node(key, Config::NoValue());
|
| + root_ = new(allocator) Node(key, Config::NoValue());
|
| } else {
|
| // Splay on the key to move the last node on the search path
|
| // for the key to the root of the tree.
|
| @@ -57,7 +59,7 @@ bool SplayTree<Config, Allocator>::Insert(const Key& key, Locator* locator) {
|
| return false;
|
| }
|
| // Insert the new node.
|
| - Node* node = new Node(key, Config::NoValue());
|
| + Node* node = new(allocator) Node(key, Config::NoValue());
|
| InsertInternal(cmp, node);
|
| }
|
| locator->bind(root_);
|
| @@ -291,15 +293,16 @@ void SplayTree<Config, Allocator>::ForEach(Callback* callback) {
|
|
|
|
|
| template <typename Config, class Allocator> template <class Callback>
|
| -void SplayTree<Config, Allocator>::ForEachNode(Callback* callback) {
|
| +void SplayTree<Config, Allocator>::ForEachNode(Callback* callback,
|
| + Allocator allocator) {
|
| // Pre-allocate some space for tiny trees.
|
| List<Node*, Allocator> nodes_to_visit(10);
|
| - if (root_ != NULL) nodes_to_visit.Add(root_);
|
| + if (root_ != NULL) nodes_to_visit.Add(root_, allocator);
|
| int pos = 0;
|
| while (pos < nodes_to_visit.length()) {
|
| Node* node = nodes_to_visit[pos++];
|
| - if (node->left() != NULL) nodes_to_visit.Add(node->left());
|
| - if (node->right() != NULL) nodes_to_visit.Add(node->right());
|
| + if (node->left() != NULL) nodes_to_visit.Add(node->left(), allocator);
|
| + if (node->right() != NULL) nodes_to_visit.Add(node->right(), allocator);
|
| callback->Call(node);
|
| }
|
| }
|
|
|