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