Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(28)

Side by Side Diff: src/utils.h

Issue 8732: Character classes (Closed)
Patch Set: Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 public: 276 public:
277 Vector() : start_(NULL), length_(0) {} 277 Vector() : start_(NULL), length_(0) {}
278 Vector(T* data, int length) : start_(data), length_(length) { 278 Vector(T* data, int length) : start_(data), length_(length) {
279 ASSERT(length == 0 || (length > 0 && data != NULL)); 279 ASSERT(length == 0 || (length > 0 && data != NULL));
280 } 280 }
281 281
282 static Vector<T> New(int length) { 282 static Vector<T> New(int length) {
283 return Vector<T>(NewArray<T>(length), length); 283 return Vector<T>(NewArray<T>(length), length);
284 } 284 }
285 285
286 // Returns a vector using the same backing storage as this one,
287 // spanning from and including 'from', to but not including 'to'.
288 Vector<T> SubVector(int from, int to) {
289 ASSERT(from < length_);
290 ASSERT(to <= length_);
291 ASSERT(from < to);
292 return Vector<T>(start() + from, to - from);
293 }
294
286 // Returns the length of the vector. 295 // Returns the length of the vector.
287 int length() const { return length_; } 296 int length() const { return length_; }
288 297
289 // Returns whether or not the vector is empty. 298 // Returns whether or not the vector is empty.
290 bool is_empty() const { return length_ == 0; } 299 bool is_empty() const { return length_ == 0; }
291 300
292 // Returns the pointer to the start of the data in the vector. 301 // Returns the pointer to the start of the data in the vector.
293 T* start() const { return start_; } 302 T* start() const { return start_; }
294 303
295 // Access individual vector elements - checks bounds in debug mode. 304 // Access individual vector elements - checks bounds in debug mode.
296 T& operator[](int index) const { 305 T& operator[](int index) const {
297 ASSERT(0 <= index && index < length_); 306 ASSERT(0 <= index && index < length_);
298 return start_[index]; 307 return start_[index];
299 } 308 }
300 309
310 T& first() { return start_[0]; }
311
312 T& last() { return start_[length_ - 1]; }
313
301 // Returns a clone of this vector with a new backing store. 314 // Returns a clone of this vector with a new backing store.
302 Vector<T> Clone() const { 315 Vector<T> Clone() const {
303 T* result = NewArray<T>(length_); 316 T* result = NewArray<T>(length_);
304 for (int i = 0; i < length_; i++) result[i] = start_[i]; 317 for (int i = 0; i < length_; i++) result[i] = start_[i];
305 return Vector<T>(result, length_); 318 return Vector<T>(result, length_);
306 } 319 }
307 320
308 // Releases the array underlying this vector. Once disposed the 321 // Releases the array underlying this vector. Once disposed the
309 // vector is empty. 322 // vector is empty.
310 void Dispose() { 323 void Dispose() {
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 } 474 }
462 #endif 475 #endif
463 while (dest < limit) { 476 while (dest < limit) {
464 *dest++ = static_cast<sinkchar>(*src++); 477 *dest++ = static_cast<sinkchar>(*src++);
465 } 478 }
466 } 479 }
467 480
468 } } // namespace v8::internal 481 } } // namespace v8::internal
469 482
470 #endif // V8_UTILS_H_ 483 #endif // V8_UTILS_H_
OLDNEW
« src/jsregexp.cc ('K') | « src/jsregexp-inl.h ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698