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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 DCHECK(0 <= index && index < length_); | 51 DCHECK(0 <= index && index < length_); |
52 return start_[index]; | 52 return start_[index]; |
53 } | 53 } |
54 | 54 |
55 const T& at(int index) const { return operator[](index); } | 55 const T& at(int index) const { return operator[](index); } |
56 | 56 |
57 T& first() { return start_[0]; } | 57 T& first() { return start_[0]; } |
58 | 58 |
59 T& last() { return start_[length_ - 1]; } | 59 T& last() { return start_[length_ - 1]; } |
60 | 60 |
| 61 typedef T* iterator; |
| 62 inline iterator begin() const { return &start_[0]; } |
| 63 inline iterator end() const { return &start_[length_]; } |
| 64 |
61 // Returns a clone of this vector with a new backing store. | 65 // Returns a clone of this vector with a new backing store. |
62 Vector<T> Clone() const { | 66 Vector<T> Clone() const { |
63 T* result = NewArray<T>(length_); | 67 T* result = NewArray<T>(length_); |
64 for (int i = 0; i < length_; i++) result[i] = start_[i]; | 68 for (int i = 0; i < length_; i++) result[i] = start_[i]; |
65 return Vector<T>(result, length_); | 69 return Vector<T>(result, length_); |
66 } | 70 } |
67 | 71 |
68 void Sort(int (*cmp)(const T*, const T*)) { | 72 void Sort(int (*cmp)(const T*, const T*)) { |
69 std::sort(start(), start() + length(), RawComparer(cmp)); | 73 std::sort(start(), start() + length(), RawComparer(cmp)); |
70 } | 74 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 177 |
174 inline Vector<char> MutableCStrVector(char* data, int max) { | 178 inline Vector<char> MutableCStrVector(char* data, int max) { |
175 int length = StrLength(data); | 179 int length = StrLength(data); |
176 return Vector<char>(data, (length < max) ? length : max); | 180 return Vector<char>(data, (length < max) ? length : max); |
177 } | 181 } |
178 | 182 |
179 | 183 |
180 } } // namespace v8::internal | 184 } } // namespace v8::internal |
181 | 185 |
182 #endif // V8_VECTOR_H_ | 186 #endif // V8_VECTOR_H_ |
OLD | NEW |