OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/basictypes.h" |
12 #include "base/stl_util-inl.h" | 12 #include "base/stl_util-inl.h" |
13 | 13 |
14 // ScopedVector wraps a vector deleting the elements from its | 14 // ScopedVector wraps a vector deleting the elements from its |
15 // destructor. | 15 // destructor. |
16 template <class T> | 16 template <class T> |
17 class ScopedVector { | 17 class ScopedVector { |
18 public: | 18 public: |
19 typedef typename std::vector<T*>::iterator iterator; | 19 typedef typename std::vector<T*>::iterator iterator; |
20 typedef typename std::vector<T*>::const_iterator const_iterator; | 20 typedef typename std::vector<T*>::const_iterator const_iterator; |
21 typedef typename std::vector<T*>::reverse_iterator reverse_iterator; | 21 typedef typename std::vector<T*>::reverse_iterator reverse_iterator; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void reset() { STLDeleteElements(&v); } | 56 void reset() { STLDeleteElements(&v); } |
57 void resize(size_t new_size) { v.resize(new_size); } | 57 void resize(size_t new_size) { v.resize(new_size); } |
58 | 58 |
59 private: | 59 private: |
60 std::vector<T*> v; | 60 std::vector<T*> v; |
61 | 61 |
62 DISALLOW_COPY_AND_ASSIGN(ScopedVector); | 62 DISALLOW_COPY_AND_ASSIGN(ScopedVector); |
63 }; | 63 }; |
64 | 64 |
65 #endif // BASE_SCOPED_VECTOR_H_ | 65 #endif // BASE_SCOPED_VECTOR_H_ |
OLD | NEW |