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

Side by Side Diff: base/scoped_vector.h

Issue 3163003: Mac tabpose: Add thumbnails (Closed)
Patch Set: '' Created 10 years, 3 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 | « no previous file | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 const std::vector<T*>& get() const { return v; } 49 const std::vector<T*>& get() const { return v; }
50 void swap(ScopedVector<T>& other) { v.swap(other.v); } 50 void swap(ScopedVector<T>& other) { v.swap(other.v); }
51 void release(std::vector<T*>* out) { 51 void release(std::vector<T*>* out) {
52 out->swap(v); 52 out->swap(v);
53 v.clear(); 53 v.clear();
54 } 54 }
55 55
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 // Lets the ScopedVector take ownership of |x|.
60 iterator insert(iterator position, T* x) {
61 return v.insert(position, x);
62 }
63
64 iterator erase(iterator position) {
65 delete *position;
66 return v.erase(position);
67 }
68
69 iterator erase(iterator first, iterator last) {
70 STLDeleteContainerPointers(first, last);
71 return v.erase(first, last);
72 }
73
74 // Like |erase()|, but doesn't delete the element at |position|.
75 iterator weak_erase(iterator position) {
76 return v.erase(position);
77 }
78
79 // Like |erase()|, but doesn't delete the elements in [first, last).
80 iterator weak_erase(iterator first, iterator last) {
81 return v.erase(first, last);
82 }
59 private: 83 private:
60 std::vector<T*> v; 84 std::vector<T*> v;
61 85
62 DISALLOW_COPY_AND_ASSIGN(ScopedVector); 86 DISALLOW_COPY_AND_ASSIGN(ScopedVector);
63 }; 87 };
64 88
65 #endif // BASE_SCOPED_VECTOR_H_ 89 #endif // BASE_SCOPED_VECTOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698