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

Side by Side Diff: third_party/WebKit/Source/wtf/HashSetTest.cpp

Issue 1846473002: WTF: Implement move of Deques. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/Source/wtf/HashMapTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 EXPECT_TRUE(isDeleted); 201 EXPECT_TRUE(isDeleted);
202 EXPECT_TRUE(set.isEmpty()); 202 EXPECT_TRUE(set.isEmpty());
203 EXPECT_EQ(1, DummyRefCounted::s_refInvokesCount); 203 EXPECT_EQ(1, DummyRefCounted::s_refInvokesCount);
204 } 204 }
205 205
206 class CountCopy final { 206 class CountCopy final {
207 public: 207 public:
208 static int* const kDeletedValue; 208 static int* const kDeletedValue;
209 209
210 explicit CountCopy(int* counter = nullptr) : m_counter(counter) { } 210 explicit CountCopy(int* counter = nullptr) : m_counter(counter) { }
211 CountCopy(const CountCopy& other) : m_counter(other.m_counter) 211 CountCopy(const CountCopy& other)
212 : m_counter(other.m_counter)
212 { 213 {
213 if (m_counter && m_counter != kDeletedValue) 214 if (m_counter && m_counter != kDeletedValue)
214 ++*m_counter; 215 ++*m_counter;
215 } 216 }
217 CountCopy& operator=(const CountCopy& other)
218 {
219 m_counter = other.m_counter;
220 if (m_counter && m_counter != kDeletedValue)
221 ++*m_counter;
222 return *this;
223 }
216 const int* counter() const { return m_counter; } 224 const int* counter() const { return m_counter; }
217 225
218 private: 226 private:
219 int* m_counter; 227 int* m_counter;
220 }; 228 };
221 229
222 int* const CountCopy::kDeletedValue = reinterpret_cast<int*>(static_cast<uintptr _t>(-1)); 230 int* const CountCopy::kDeletedValue = reinterpret_cast<int*>(static_cast<uintptr _t>(-1));
223 231
224 struct CountCopyHashTraits : public GenericHashTraits<CountCopy> { 232 struct CountCopyHashTraits : public GenericHashTraits<CountCopy> {
225 static const bool emptyValueIsZero = false; 233 static const bool emptyValueIsZero = false;
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 EXPECT_EQ(13, thirteen.id()); 393 EXPECT_EQ(13, thirteen.id());
386 iter = set.find(MoveOnly(13)); 394 iter = set.find(MoveOnly(13));
387 EXPECT_TRUE(iter == set.end()); 395 EXPECT_TRUE(iter == set.end());
388 396
389 set.clear(); 397 set.clear();
390 } 398 }
391 399
392 } // anonymous namespace 400 } // anonymous namespace
393 401
394 } // namespace WTF 402 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/HashMapTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698