| Index: src/utils.h
|
| diff --git a/src/utils.h b/src/utils.h
|
| index 9f2407973d728e8495ea69a915d3a838e8442603..73585932d7bf1df50c9aa214de8a4067517461f5 100644
|
| --- a/src/utils.h
|
| +++ b/src/utils.h
|
| @@ -283,6 +283,15 @@ class Vector {
|
| return Vector<T>(NewArray<T>(length), length);
|
| }
|
|
|
| + // Returns a vector using the same backing storage as this one,
|
| + // spanning from and including 'from', to but not including 'to'.
|
| + Vector<T> SubVector(int from, int to) {
|
| + ASSERT(from < length_);
|
| + ASSERT(to <= length_);
|
| + ASSERT(from < to);
|
| + return Vector<T>(start() + from, to - from);
|
| + }
|
| +
|
| // Returns the length of the vector.
|
| int length() const { return length_; }
|
|
|
| @@ -298,6 +307,10 @@ class Vector {
|
| return start_[index];
|
| }
|
|
|
| + T& first() { return start_[0]; }
|
| +
|
| + T& last() { return start_[length_ - 1]; }
|
| +
|
| // Returns a clone of this vector with a new backing store.
|
| Vector<T> Clone() const {
|
| T* result = NewArray<T>(length_);
|
|
|