Chromium Code Reviews| Index: Source/wtf/RefVector.h |
| diff --git a/Source/wtf/RefVector.h b/Source/wtf/RefVector.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5117ce9cdb9a8d2875f4bf911defb2b92766f12d |
| --- /dev/null |
| +++ b/Source/wtf/RefVector.h |
| @@ -0,0 +1,40 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef RefVector_h |
| +#define RefVector_h |
| + |
| +#include "wtf/RefCounted.h" |
| +#include "wtf/RefPtr.h" |
| +#include "wtf/Vector.h" |
| + |
| +namespace WebCore { |
| + |
| +template <typename T> |
| +class RefVector : public RefCounted<RefVector<T> > { |
| +public: |
| + static PassRefPtr<RefVector> create() { return adoptRef(new RefVector<T>); } |
| + PassRefPtr<RefVector> copy() { return adoptRef(new RefVector<T>(*this)); } |
| + |
| + const T& operator[](size_t i) const { return m_vector[i]; } |
| + T& operator[](size_t i) { return m_vector[i]; } |
| + const T& at(size_t i) const { return m_vector.at(i); } |
| + T& at(size_t i) { return m_vector.at(i); } |
|
Julien - ping for review
2014/05/05 17:45:08
The at() functions are not used in the patch, coul
andersr
2014/05/06 13:15:29
Done.
|
| + |
| + bool operator==(const RefVector& o) const { return m_vector == o.m_vector; } |
| + bool operator!=(const RefVector& o) const { return m_vector != o.m_vector; } |
| + |
| + size_t size() const { return m_vector.size(); } |
| + void append(const T& decoration) { m_vector.append(decoration); } |
| + const Vector<T>& vector() const { return m_vector; } |
| + |
| +private: |
| + Vector<T> m_vector; |
| + RefVector() { } |
| + RefVector(const RefVector& o) : m_vector(o.m_vector) { } |
| +}; |
| + |
| +} // namespace WebCore |
| + |
| +#endif // RefVector_h |