OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 qsort(start(), | 355 qsort(start(), |
356 length(), | 356 length(), |
357 sizeof(T), | 357 sizeof(T), |
358 reinterpret_cast<RawComparer>(cmp)); | 358 reinterpret_cast<RawComparer>(cmp)); |
359 } | 359 } |
360 | 360 |
361 void Sort() { | 361 void Sort() { |
362 Sort(PointerValueCompare<T>); | 362 Sort(PointerValueCompare<T>); |
363 } | 363 } |
364 | 364 |
| 365 void Truncate(int length) { |
| 366 ASSERT(length <= length_); |
| 367 length_ = length; |
| 368 } |
| 369 |
365 // Releases the array underlying this vector. Once disposed the | 370 // Releases the array underlying this vector. Once disposed the |
366 // vector is empty. | 371 // vector is empty. |
367 void Dispose() { | 372 void Dispose() { |
368 if (is_empty()) return; | 373 if (is_empty()) return; |
369 DeleteArray(start_); | 374 DeleteArray(start_); |
370 start_ = NULL; | 375 start_ = NULL; |
371 length_ = 0; | 376 length_ = 0; |
372 } | 377 } |
373 | 378 |
374 inline Vector<T> operator+(int offset) { | 379 inline Vector<T> operator+(int offset) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
565 #endif | 570 #endif |
566 while (dest < limit) { | 571 while (dest < limit) { |
567 *dest++ = static_cast<sinkchar>(*src++); | 572 *dest++ = static_cast<sinkchar>(*src++); |
568 } | 573 } |
569 } | 574 } |
570 | 575 |
571 | 576 |
572 } } // namespace v8::internal | 577 } } // namespace v8::internal |
573 | 578 |
574 #endif // V8_UTILS_H_ | 579 #endif // V8_UTILS_H_ |
OLD | NEW |