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

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

Issue 22144006: Un-revert "Implement simple effect typing for variables" and "Handle switch effects" (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix building with clang Created 7 years, 4 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/effects.h ('k') | src/splay-tree-inl.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 21 matching lines...) Expand all
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 36
37 // A splay tree. The config type parameter encapsulates the different 37 // A splay tree. The config type parameter encapsulates the different
38 // configurations of a concrete splay tree: 38 // configurations of a concrete splay tree:
39 // 39 //
40 // typedef Key: the key type 40 // typedef Key: the key type
41 // typedef Value: the value type 41 // typedef Value: the value type
42 // static const kNoKey: the dummy key used when no key is set 42 // static const Key kNoKey: the dummy key used when no key is set
43 // static const kNoValue: the dummy value used to initialize nodes 43 // static Value kNoValue(): the dummy value used to initialize nodes
44 // int (Compare)(Key& a, Key& b) -> {-1, 0, 1}: comparison function 44 // static int (Compare)(Key& a, Key& b) -> {-1, 0, 1}: comparison function
45 // 45 //
46 // The tree is also parameterized by an allocation policy 46 // The tree is also parameterized by an allocation policy
47 // (Allocator). The policy is used for allocating lists in the C free 47 // (Allocator). The policy is used for allocating lists in the C free
48 // store or the zone; see zone.h. 48 // store or the zone; see zone.h.
49 49
50 // Forward defined as 50 // Forward defined as
51 // template <typename Config, class Allocator = FreeStoreAllocationPolicy> 51 // template <typename Config, class Allocator = FreeStoreAllocationPolicy>
52 // class SplayTree; 52 // class SplayTree;
53 template <typename Config, class AllocationPolicy> 53 template <typename Config, class AllocationPolicy>
54 class SplayTree { 54 class SplayTree {
(...skipping 12 matching lines...) Expand all
67 return allocator.New(static_cast<int>(size)); 67 return allocator.New(static_cast<int>(size));
68 } 68 }
69 INLINE(void operator delete(void* p)) { 69 INLINE(void operator delete(void* p)) {
70 AllocationPolicy::Delete(p); 70 AllocationPolicy::Delete(p);
71 } 71 }
72 // Please the MSVC compiler. We should never have to execute this. 72 // Please the MSVC compiler. We should never have to execute this.
73 INLINE(void operator delete(void* p, AllocationPolicy policy)) { 73 INLINE(void operator delete(void* p, AllocationPolicy policy)) {
74 UNREACHABLE(); 74 UNREACHABLE();
75 } 75 }
76 76
77 AllocationPolicy allocator() { return allocator_; }
78
79 // Checks if there is a mapping for the key.
80 bool Contains(const Key& key);
81
77 // Inserts the given key in this tree with the given value. Returns 82 // Inserts the given key in this tree with the given value. Returns
78 // true if a node was inserted, otherwise false. If found the locator 83 // true if a node was inserted, otherwise false. If found the locator
79 // is enabled and provides access to the mapping for the key. 84 // is enabled and provides access to the mapping for the key.
80 bool Insert(const Key& key, Locator* locator); 85 bool Insert(const Key& key, Locator* locator);
81 86
82 // Looks up the key in this tree and returns true if it was found, 87 // Looks up the key in this tree and returns true if it was found,
83 // otherwise false. If the node is found the locator is enabled and 88 // otherwise false. If the node is found the locator is enabled and
84 // provides access to the mapping for the key. 89 // provides access to the mapping for the key.
85 bool Find(const Key& key, Locator* locator); 90 bool Find(const Key& key, Locator* locator);
86 91
(...skipping 10 matching lines...) Expand all
97 102
98 // Find the mapping with the least key in this tree. 103 // Find the mapping with the least key in this tree.
99 bool FindLeast(Locator* locator); 104 bool FindLeast(Locator* locator);
100 105
101 // Move the node from one key to another. 106 // Move the node from one key to another.
102 bool Move(const Key& old_key, const Key& new_key); 107 bool Move(const Key& old_key, const Key& new_key);
103 108
104 // Remove the node with the given key from the tree. 109 // Remove the node with the given key from the tree.
105 bool Remove(const Key& key); 110 bool Remove(const Key& key);
106 111
112 // Remove all keys from the tree.
113 void Clear() { ResetRoot(); }
114
107 bool is_empty() { return root_ == NULL; } 115 bool is_empty() { return root_ == NULL; }
108 116
109 // Perform the splay operation for the given key. Moves the node with 117 // Perform the splay operation for the given key. Moves the node with
110 // the given key to the top of the tree. If no node has the given 118 // the given key to the top of the tree. If no node has the given
111 // key, the last node on the search path is moved to the top of the 119 // key, the last node on the search path is moved to the top of the
112 // tree. 120 // tree.
113 void Splay(const Key& key); 121 void Splay(const Key& key);
114 122
115 class Node { 123 class Node {
116 public: 124 public:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 Node* root_; 217 Node* root_;
210 AllocationPolicy allocator_; 218 AllocationPolicy allocator_;
211 219
212 DISALLOW_COPY_AND_ASSIGN(SplayTree); 220 DISALLOW_COPY_AND_ASSIGN(SplayTree);
213 }; 221 };
214 222
215 223
216 } } // namespace v8::internal 224 } } // namespace v8::internal
217 225
218 #endif // V8_SPLAY_TREE_H_ 226 #endif // V8_SPLAY_TREE_H_
OLDNEW
« no previous file with comments | « src/effects.h ('k') | src/splay-tree-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698