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

Side by Side Diff: test/cctest/test-hashmap.cc

Issue 1074943002: Split TemplateHashMapImpl::Lookup into two methods (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix arm (and ppc) builds Created 5 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
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 30 matching lines...) Expand all
41 41
42 typedef uint32_t (*IntKeyHash)(uint32_t key); 42 typedef uint32_t (*IntKeyHash)(uint32_t key);
43 43
44 44
45 class IntSet { 45 class IntSet {
46 public: 46 public:
47 explicit IntSet(IntKeyHash hash) : hash_(hash), map_(DefaultMatchFun) {} 47 explicit IntSet(IntKeyHash hash) : hash_(hash), map_(DefaultMatchFun) {}
48 48
49 void Insert(int x) { 49 void Insert(int x) {
50 CHECK_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value 50 CHECK_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value
51 HashMap::Entry* p = map_.Lookup(reinterpret_cast<void*>(x), hash_(x), true); 51 HashMap::Entry* p =
52 map_.LookupOrInsert(reinterpret_cast<void*>(x), hash_(x));
52 CHECK(p != NULL); // insert is set! 53 CHECK(p != NULL); // insert is set!
53 CHECK_EQ(reinterpret_cast<void*>(x), p->key); 54 CHECK_EQ(reinterpret_cast<void*>(x), p->key);
54 // we don't care about p->value 55 // we don't care about p->value
55 } 56 }
56 57
57 void Remove(int x) { 58 void Remove(int x) {
58 CHECK_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value 59 CHECK_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value
59 map_.Remove(reinterpret_cast<void*>(x), hash_(x)); 60 map_.Remove(reinterpret_cast<void*>(x), hash_(x));
60 } 61 }
61 62
62 bool Present(int x) { 63 bool Present(int x) {
63 HashMap::Entry* p = 64 HashMap::Entry* p = map_.Lookup(reinterpret_cast<void*>(x), hash_(x));
64 map_.Lookup(reinterpret_cast<void*>(x), hash_(x), false);
65 if (p != NULL) { 65 if (p != NULL) {
66 CHECK_EQ(reinterpret_cast<void*>(x), p->key); 66 CHECK_EQ(reinterpret_cast<void*>(x), p->key);
67 } 67 }
68 return p != NULL; 68 return p != NULL;
69 } 69 }
70 70
71 void Clear() { 71 void Clear() {
72 map_.Clear(); 72 map_.Clear();
73 } 73 }
74 74
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 168 }
169 } 169 }
170 CHECK_EQ(0u, set.occupancy()); 170 CHECK_EQ(0u, set.occupancy());
171 } 171 }
172 172
173 173
174 TEST(Set) { 174 TEST(Set) {
175 TestSet(Hash, 100); 175 TestSet(Hash, 100);
176 TestSet(CollisionHash, 50); 176 TestSet(CollisionHash, 50);
177 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698