| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project 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 V8_VECTOR_H_ | 5 #ifndef V8_VECTOR_H_ |
| 6 #define V8_VECTOR_H_ | 6 #define V8_VECTOR_H_ |
| 7 | 7 |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 DeleteArray(start_); | 112 DeleteArray(start_); |
| 113 start_ = NULL; | 113 start_ = NULL; |
| 114 length_ = 0; | 114 length_ = 0; |
| 115 } | 115 } |
| 116 | 116 |
| 117 inline Vector<T> operator+(int offset) { | 117 inline Vector<T> operator+(int offset) { |
| 118 DCHECK(offset < length_); | 118 DCHECK(offset < length_); |
| 119 return Vector<T>(start_ + offset, length_ - offset); | 119 return Vector<T>(start_ + offset, length_ - offset); |
| 120 } | 120 } |
| 121 | 121 |
| 122 // Implicit conversion from Vector<T> to Vector<const T>. |
| 123 inline operator Vector<const T>() { return Vector<const T>::cast(*this); } |
| 124 |
| 122 // Factory method for creating empty vectors. | 125 // Factory method for creating empty vectors. |
| 123 static Vector<T> empty() { return Vector<T>(NULL, 0); } | 126 static Vector<T> empty() { return Vector<T>(NULL, 0); } |
| 124 | 127 |
| 125 template<typename S> | 128 template<typename S> |
| 126 static Vector<T> cast(Vector<S> input) { | 129 static Vector<T> cast(Vector<S> input) { |
| 127 return Vector<T>(reinterpret_cast<T*>(input.start()), | 130 return Vector<T>(reinterpret_cast<T*>(input.start()), |
| 128 input.length() * sizeof(S) / sizeof(T)); | 131 input.length() * sizeof(S) / sizeof(T)); |
| 129 } | 132 } |
| 130 | 133 |
| 131 bool operator==(const Vector<T>& other) const { | 134 bool operator==(const Vector<T>& other) const { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 210 |
| 208 template <typename T, int N> | 211 template <typename T, int N> |
| 209 inline Vector<T> ArrayVector(T (&arr)[N]) { | 212 inline Vector<T> ArrayVector(T (&arr)[N]) { |
| 210 return Vector<T>(arr); | 213 return Vector<T>(arr); |
| 211 } | 214 } |
| 212 | 215 |
| 213 } // namespace internal | 216 } // namespace internal |
| 214 } // namespace v8 | 217 } // namespace v8 |
| 215 | 218 |
| 216 #endif // V8_VECTOR_H_ | 219 #endif // V8_VECTOR_H_ |
| OLD | NEW |