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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 inline iterator begin() const { return &start_[0]; } | 62 inline iterator begin() const { return &start_[0]; } |
63 inline iterator end() const { return &start_[length_]; } | 63 inline iterator end() const { return &start_[length_]; } |
64 | 64 |
65 // Returns a clone of this vector with a new backing store. | 65 // Returns a clone of this vector with a new backing store. |
66 Vector<T> Clone() const { | 66 Vector<T> Clone() const { |
67 T* result = NewArray<T>(length_); | 67 T* result = NewArray<T>(length_); |
68 for (int i = 0; i < length_; i++) result[i] = start_[i]; | 68 for (int i = 0; i < length_; i++) result[i] = start_[i]; |
69 return Vector<T>(result, length_); | 69 return Vector<T>(result, length_); |
70 } | 70 } |
71 | 71 |
| 72 void Sort(int (*cmp)(const T*, const T*), size_t s, size_t l) { |
| 73 std::sort(start() + s, start() + s + l, RawComparer(cmp)); |
| 74 } |
| 75 |
72 void Sort(int (*cmp)(const T*, const T*)) { | 76 void Sort(int (*cmp)(const T*, const T*)) { |
73 std::sort(start(), start() + length(), RawComparer(cmp)); | 77 std::sort(start(), start() + length(), RawComparer(cmp)); |
74 } | 78 } |
75 | 79 |
76 void Sort() { | 80 void Sort() { |
77 std::sort(start(), start() + length()); | 81 std::sort(start(), start() + length()); |
78 } | 82 } |
79 | 83 |
| 84 void StableSort(int (*cmp)(const T*, const T*), size_t s, size_t l) { |
| 85 std::stable_sort(start() + s, start() + s + l, RawComparer(cmp)); |
| 86 } |
| 87 |
| 88 void StableSort(int (*cmp)(const T*, const T*)) { |
| 89 std::stable_sort(start(), start() + length(), RawComparer(cmp)); |
| 90 } |
| 91 |
| 92 void StableSort() { std::stable_sort(start(), start() + length()); } |
| 93 |
80 void Truncate(int length) { | 94 void Truncate(int length) { |
81 DCHECK(length <= length_); | 95 DCHECK(length <= length_); |
82 length_ = length; | 96 length_ = length; |
83 } | 97 } |
84 | 98 |
85 // Releases the array underlying this vector. Once disposed the | 99 // Releases the array underlying this vector. Once disposed the |
86 // vector is empty. | 100 // vector is empty. |
87 void Dispose() { | 101 void Dispose() { |
88 DeleteArray(start_); | 102 DeleteArray(start_); |
89 start_ = NULL; | 103 start_ = NULL; |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 191 |
178 inline Vector<char> MutableCStrVector(char* data, int max) { | 192 inline Vector<char> MutableCStrVector(char* data, int max) { |
179 int length = StrLength(data); | 193 int length = StrLength(data); |
180 return Vector<char>(data, (length < max) ? length : max); | 194 return Vector<char>(data, (length < max) ? length : max); |
181 } | 195 } |
182 | 196 |
183 | 197 |
184 } } // namespace v8::internal | 198 } } // namespace v8::internal |
185 | 199 |
186 #endif // V8_VECTOR_H_ | 200 #endif // V8_VECTOR_H_ |
OLD | NEW |