21 #include "mongo/base/disallow_copying.h"
58 typedef typename std::vector<T*>::const_iterator const_iterator;
59 typedef typename std::vector<T*>::const_reverse_iterator const_reverse_iterator;
62 const std::vector<T*>&
vector()
const {
65 std::vector<T*>& mutableVector() {
69 std::size_t size()
const {
70 return _vector.size();
73 return _vector.empty();
76 const_iterator begin()
const {
77 return _vector.begin();
79 const_reverse_iterator rbegin()
const {
80 return _vector.rbegin();
82 const_iterator end()
const {
85 const_reverse_iterator rend()
const {
86 return _vector.rend();
89 T* operator[](
size_t i)
const {
93 return _vector.back();
96 return _vector.front();
99 void push_back(T* ptr) {
100 _vector.push_back(ptr);
113 _vector.erase(toNonConstIter(it));
116 void erase(const_iterator begin, const_iterator end) {
117 for (const_iterator it = begin; it != end; ++it) {
120 _vector.erase(toNonConstIter(begin), toNonConstIter(end));
150 T* popAndReleaseBack() {
151 T* out = _vector.back();
156 void popAndDeleteBack() {
157 delete popAndReleaseBack();
161 typename std::vector<T*>::iterator toNonConstIter(const_iterator it) {
164 return _vector.begin() + (it - begin());
167 std::vector<T*> _vector;
172 for (
typename std::vector<T*>::iterator i = _vector.begin(); i != _vector.end(); ++i) {
OwnedPointerVector(std::vector< T * > other)
Takes ownership of all pointers contained in 'other'.
Definition: owned_pointer_vector.h:44
void clear()
Deletes all pointers in the vector, then sets its size to 0.
Definition: owned_pointer_vector.h:171
const std::vector< T * > & vector() const
Access the vector.
Definition: owned_pointer_vector.h:62
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
An std::vector wrapper that deletes pointers within a vector on destruction.
Definition: owned_pointer_vector.h:31
OwnedPointerVector & operator=(std::vector< T * > other)
Takes ownership of all pointers contained in 'other'.
Definition: owned_pointer_vector.h:52
std::vector< T * > release()
Releases the entire vector to allow you to transfer ownership.
Definition: owned_pointer_vector.h:133
void erase(const_iterator it)
Deletes the pointer at 'it', then erases it from the vector.
Definition: owned_pointer_vector.h:111
T * releaseAt(size_t i)
Releases ownership of a single element.
Definition: owned_pointer_vector.h:144