OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_SCOPED_VECTOR_H_ | 5 #ifndef BASE_SCOPED_VECTOR_H_ |
6 #define BASE_SCOPED_VECTOR_H_ | 6 #define BASE_SCOPED_VECTOR_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 iterator begin() { return v.begin(); } | 32 iterator begin() { return v.begin(); } |
33 const_iterator begin() const { return v.begin(); } | 33 const_iterator begin() const { return v.begin(); } |
34 iterator end() { return v.end(); } | 34 iterator end() { return v.end(); } |
35 const_iterator end() const { return v.end(); } | 35 const_iterator end() const { return v.end(); } |
36 | 36 |
37 void push_back(T* elem) { v.push_back(elem); } | 37 void push_back(T* elem) { v.push_back(elem); } |
38 | 38 |
39 std::vector<T*>& get() { return v; } | 39 std::vector<T*>& get() { return v; } |
40 const std::vector<T*>& get() const { return v; } | 40 const std::vector<T*>& get() const { return v; } |
41 void swap(ScopedVector<T>& other) { v.swap(other.v); } | 41 void swap(ScopedVector<T>& other) { v.swap(other.v); } |
42 void release(std::vector<T*>* out) { | 42 void release(std::vector<T*>* out) { out->swap(v); v.clear(); } |
43 out->swap(v); | |
44 v.clear(); | |
45 } | |
46 | 43 |
47 void reset() { STLDeleteElements(&v); } | 44 void reset() { STLDeleteElements(&v); } |
48 | 45 |
49 private: | 46 private: |
50 std::vector<T*> v; | 47 std::vector<T*> v; |
51 | 48 |
52 DISALLOW_COPY_AND_ASSIGN(ScopedVector); | 49 DISALLOW_COPY_AND_ASSIGN(ScopedVector); |
53 }; | 50 }; |
54 | 51 |
55 #endif // BASE_SCOPED_VECTOR_H_ | 52 #endif // BASE_SCOPED_VECTOR_H_ |
OLD | NEW |