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

Side by Side Diff: src/hashmap.h

Issue 239133002: Refactoring: HashMap: provide a pointer match function, so users don't need to. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 8 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/debug.h ('k') | src/heap-snapshot-generator.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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // 91 //
92 // for (Entry* p = map.Start(); p != NULL; p = map.Next(p)) { 92 // for (Entry* p = map.Start(); p != NULL; p = map.Next(p)) {
93 // ... 93 // ...
94 // } 94 // }
95 // 95 //
96 // If entries are inserted during iteration, the effect of 96 // If entries are inserted during iteration, the effect of
97 // calling Next() is undefined. 97 // calling Next() is undefined.
98 Entry* Start() const; 98 Entry* Start() const;
99 Entry* Next(Entry* p) const; 99 Entry* Next(Entry* p) const;
100 100
101 // Some match functions defined for convenience.
102 static bool PointersMatch(void* key1, void* key2) {
103 return key1 == key2;
104 }
105
101 private: 106 private:
102 MatchFun match_; 107 MatchFun match_;
103 Entry* map_; 108 Entry* map_;
104 uint32_t capacity_; 109 uint32_t capacity_;
105 uint32_t occupancy_; 110 uint32_t occupancy_;
106 111
107 Entry* map_end() const { return map_ + capacity_; } 112 Entry* map_end() const { return map_ + capacity_; }
108 Entry* Probe(void* key, uint32_t hash); 113 Entry* Probe(void* key, uint32_t hash);
109 void Initialize(uint32_t capacity, AllocationPolicy allocator); 114 void Initialize(uint32_t capacity, AllocationPolicy allocator);
110 void Resize(AllocationPolicy allocator); 115 void Resize(AllocationPolicy allocator);
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 Iterator end() const { return Iterator(this, NULL); } 360 Iterator end() const { return Iterator(this, NULL); }
356 Iterator find(Key* key, bool insert = false, 361 Iterator find(Key* key, bool insert = false,
357 AllocationPolicy allocator = AllocationPolicy()) { 362 AllocationPolicy allocator = AllocationPolicy()) {
358 return Iterator(this, this->Lookup(key, key->Hash(), insert, allocator)); 363 return Iterator(this, this->Lookup(key, key->Hash(), insert, allocator));
359 } 364 }
360 }; 365 };
361 366
362 } } // namespace v8::internal 367 } } // namespace v8::internal
363 368
364 #endif // V8_HASHMAP_H_ 369 #endif // V8_HASHMAP_H_
OLDNEW
« no previous file with comments | « src/debug.h ('k') | src/heap-snapshot-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698