| 1 | // Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file |
| 2 | // for details. All rights reserved. Use of this source code is governed by a |
| 3 | // BSD-style license that can be found in the LICENSE file. |
| 4 | |
| 5 | #ifndef RUNTIME_VM_SPLAY_TREE_H_ |
| 6 | #define RUNTIME_VM_SPLAY_TREE_H_ |
| 7 | |
| 8 | #include "platform/splay-tree.h" |
| 9 | #include "vm/zone.h" |
| 10 | |
| 11 | namespace dart { |
| 12 | |
| 13 | // A zone splay tree. The config type parameter encapsulates the |
| 14 | // different configurations of a concrete splay tree (see |
| 15 | // platform/splay-tree.h). The tree itself and all its elements are allocated |
| 16 | // in the Zone. |
| 17 | template <typename Config> |
| 18 | class ZoneSplayTree final : public SplayTree<Config, ZoneAllocated, Zone> { |
| 19 | public: |
| 20 | explicit ZoneSplayTree(Zone* zone) |
| 21 | : SplayTree<Config, ZoneAllocated, Zone>(ASSERT_NOTNULL(zone)) {} |
| 22 | ~ZoneSplayTree() { |
| 23 | // Reset the root to avoid unneeded iteration over all tree nodes |
| 24 | // in the destructor. For a zone-allocated tree, nodes will be |
| 25 | // freed by the Zone. |
| 26 | SplayTree<Config, ZoneAllocated, Zone>::ResetRoot(); |
| 27 | } |
| 28 | }; |
| 29 | |
| 30 | } // namespace dart |
| 31 | |
| 32 | #endif // RUNTIME_VM_SPLAY_TREE_H_ |
| 33 | |