| 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 15 matching lines...) Expand all Loading... |
| 26 | 26 |
| 27 template <int N> | 27 template <int N> |
| 28 explicit Vector(T (&arr)[N]) : start_(arr), length_(N) {} | 28 explicit Vector(T (&arr)[N]) : start_(arr), length_(N) {} |
| 29 | 29 |
| 30 static Vector<T> New(int length) { | 30 static Vector<T> New(int length) { |
| 31 return Vector<T>(NewArray<T>(length), length); | 31 return Vector<T>(NewArray<T>(length), length); |
| 32 } | 32 } |
| 33 | 33 |
| 34 // Returns a vector using the same backing storage as this one, | 34 // Returns a vector using the same backing storage as this one, |
| 35 // spanning from and including 'from', to but not including 'to'. | 35 // spanning from and including 'from', to but not including 'to'. |
| 36 Vector<T> SubVector(int from, int to) { | 36 Vector<T> SubVector(int from, int to) const { |
| 37 DCHECK(0 <= from); | 37 DCHECK(0 <= from); |
| 38 SLOW_DCHECK(from < to); | 38 SLOW_DCHECK(from < to); |
| 39 SLOW_DCHECK(static_cast<unsigned>(to) <= static_cast<unsigned>(length_)); | 39 SLOW_DCHECK(static_cast<unsigned>(to) <= static_cast<unsigned>(length_)); |
| 40 return Vector<T>(start() + from, to - from); | 40 return Vector<T>(start() + from, to - from); |
| 41 } | 41 } |
| 42 | 42 |
| 43 // Returns the length of the vector. | 43 // Returns the length of the vector. |
| 44 int length() const { return length_; } | 44 int length() const { return length_; } |
| 45 | 45 |
| 46 // Returns whether or not the vector is empty. | 46 // Returns whether or not the vector is empty. |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 207 |
| 208 template <typename T, int N> | 208 template <typename T, int N> |
| 209 inline Vector<T> ArrayVector(T (&arr)[N]) { | 209 inline Vector<T> ArrayVector(T (&arr)[N]) { |
| 210 return Vector<T>(arr); | 210 return Vector<T>(arr); |
| 211 } | 211 } |
| 212 | 212 |
| 213 } // namespace internal | 213 } // namespace internal |
| 214 } // namespace v8 | 214 } // namespace v8 |
| 215 | 215 |
| 216 #endif // V8_VECTOR_H_ | 216 #endif // V8_VECTOR_H_ |
| OLD | NEW |