Lines Matching defs:map
17 // Tests use of const foreach(). map.count() is of course the better way to do this.
18 static int count(const SkTHashMap<int, double>& map) {
20 map.foreach([&n](int, double) { n++; });
25 SkTHashMap<int, double> map;
27 map.set(3, 4.0);
28 REPORTER_ASSERT(r, map.count() == 1);
30 REPORTER_ASSERT(r, map.approxBytesUsed() > 0);
32 double* found = map.find(3);
36 map.foreach([](int key, double* d){ *d = -key; });
37 REPORTER_ASSERT(r, count(map) == 1);
39 found = map.find(3);
43 REPORTER_ASSERT(r, !map.find(2));
48 map.set(i, 2.0*i);
51 // Test walking the map with iterators, using preincrement (++iter).
52 for (SkTHashMap<int, double>::Iter iter = map.begin(); iter != map.end(); ++iter) {
56 // Test walking the map with range-based for.
57 for (auto& entry : map) {
61 // Ensure that iteration works equally well on a const map, using postincrement (iter++).
62 const auto& cmap = map;
67 // Ensure that range-based for works equally well on a const map.
77 SkTHashMap<int, double> clone = map;
80 found = map.find(i);
89 REPORTER_ASSERT(r, !map.find(i));
93 REPORTER_ASSERT(r, map.count() == N);
97 map.remove(i);
100 found = map.find(i);
106 REPORTER_ASSERT(r, map.count() == N/2);
109 map.reset();
110 REPORTER_ASSERT(r, map.count() == 0);
113 clone = map;