| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebVector_h | 31 #ifndef WebVector_h |
| 32 #define WebVector_h | 32 #define WebVector_h |
| 33 | 33 |
| 34 #include "WebCommon.h" | 34 #include "WebCommon.h" |
| 35 #include "base/logging.h" |
| 35 | 36 |
| 36 #include <algorithm> | 37 #include <algorithm> |
| 37 #include <vector> | 38 #include <vector> |
| 38 | 39 |
| 39 namespace blink { | 40 namespace blink { |
| 40 | 41 |
| 41 // A simple vector class that wraps a std::vector. | 42 // A simple vector class that wraps a std::vector. |
| 42 // | 43 // |
| 43 // Sample usage: | 44 // Sample usage: |
| 44 // | 45 // |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void assign(const U* values, size_t size) | 118 void assign(const U* values, size_t size) |
| 118 { | 119 { |
| 119 m_data.assign(values, values + size); | 120 m_data.assign(values, values + size); |
| 120 } | 121 } |
| 121 | 122 |
| 122 size_t size() const { return m_data.size(); } | 123 size_t size() const { return m_data.size(); } |
| 123 bool isEmpty() const { return m_data.empty(); } | 124 bool isEmpty() const { return m_data.empty(); } |
| 124 | 125 |
| 125 T& operator[](size_t i) | 126 T& operator[](size_t i) |
| 126 { | 127 { |
| 127 BLINK_ASSERT(i < m_data.size()); | 128 DCHECK_LT(i, m_data.size()); |
| 128 return m_data[i]; | 129 return m_data[i]; |
| 129 } | 130 } |
| 130 | 131 |
| 131 const T& operator[](size_t i) const | 132 const T& operator[](size_t i) const |
| 132 { | 133 { |
| 133 BLINK_ASSERT(i < m_data.size()); | 134 DCHECK_LT(i, m_data.size()); |
| 134 return m_data[i]; | 135 return m_data[i]; |
| 135 } | 136 } |
| 136 | 137 |
| 137 T* data() { return m_data.data(); } | 138 T* data() { return m_data.data(); } |
| 138 const T* data() const { return m_data.data(); } | 139 const T* data() const { return m_data.data(); } |
| 139 | 140 |
| 140 iterator begin() { return m_data.begin(); } | 141 iterator begin() { return m_data.begin(); } |
| 141 iterator end() { return m_data.end(); } | 142 iterator end() { return m_data.end(); } |
| 142 const_iterator begin() const { return m_data.begin(); } | 143 const_iterator begin() const { return m_data.begin(); } |
| 143 const_iterator end() const { return m_data.end(); } | 144 const_iterator end() const { return m_data.end(); } |
| 144 | 145 |
| 145 void swap(WebVector<T>& other) | 146 void swap(WebVector<T>& other) |
| 146 { | 147 { |
| 147 m_data.swap(other.m_data); | 148 m_data.swap(other.m_data); |
| 148 } | 149 } |
| 149 | 150 |
| 150 private: | 151 private: |
| 151 std::vector<T> m_data; | 152 std::vector<T> m_data; |
| 152 }; | 153 }; |
| 153 | 154 |
| 154 } // namespace blink | 155 } // namespace blink |
| 155 | 156 |
| 156 #endif | 157 #endif |
| OLD | NEW |