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

Side by Side Diff: webrtc/base/scopedptrcollection.h

Issue 2812553002: Revert of Delete class ScopedPtrCollection. Replaced with vector of unique_ptr. (Closed)
Patch Set: Created 3 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 | « webrtc/base/criticalsection_unittest.cc ('k') | webrtc/base/scopedptrcollection_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 // Stores a collection of pointers that are deleted when the container is
12 // destructed.
13
14 #ifndef WEBRTC_BASE_SCOPEDPTRCOLLECTION_H_
15 #define WEBRTC_BASE_SCOPEDPTRCOLLECTION_H_
16
17 #include <stddef.h>
18
19 #include <algorithm>
20 #include <vector>
21
22 #include "webrtc/base/constructormagic.h"
23
24 namespace rtc {
25
26 template<class T>
27 class ScopedPtrCollection {
28 public:
29 typedef std::vector<T*> VectorT;
30
31 ScopedPtrCollection() { }
32 ~ScopedPtrCollection() {
33 for (typename VectorT::iterator it = collection_.begin();
34 it != collection_.end(); ++it) {
35 delete *it;
36 }
37 }
38
39 const VectorT& collection() const { return collection_; }
40 void Reserve(size_t size) {
41 collection_.reserve(size);
42 }
43 void PushBack(T* t) {
44 collection_.push_back(t);
45 }
46
47 // Remove |t| from the collection without deleting it.
48 void Remove(T* t) {
49 collection_.erase(std::remove(collection_.begin(), collection_.end(), t),
50 collection_.end());
51 }
52
53 private:
54 VectorT collection_;
55
56 RTC_DISALLOW_COPY_AND_ASSIGN(ScopedPtrCollection);
57 };
58
59 } // namespace rtc
60
61 #endif // WEBRTC_BASE_SCOPEDPTRCOLLECTION_H_
OLDNEW
« no previous file with comments | « webrtc/base/criticalsection_unittest.cc ('k') | webrtc/base/scopedptrcollection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698