Chromium Code Reviews| Index: include/core/SkTArray.h |
| diff --git a/include/core/SkTArray.h b/include/core/SkTArray.h |
| index dea0e38fecae7e2ac10e0f0b7b517c2847e06364..63455a28f5037146c3f127f316e7b2ffd76d95c9 100644 |
| --- a/include/core/SkTArray.h |
| +++ b/include/core/SkTArray.h |
| @@ -364,6 +364,30 @@ public: |
| return !(*this == right); |
| } |
| + int find(const T& elem) const { |
|
f(malita)
2015/02/12 17:37:47
Similar to SkTDArray's helpers.
|
| + const T* iter = fItemArray; |
| + const T* stop = fItemArray + fCount; |
| + |
| + for (; iter < stop; iter++) { |
| + if (*iter == elem) { |
| + return (int) (iter - fItemArray); |
|
reed1
2015/02/12 17:55:13
SkToInt()
f(malita)
2015/02/12 18:10:19
Done.
|
| + } |
| + } |
| + return -1; |
| + } |
| + |
| + int rfind(const T& elem) const { |
| + const T* iter = fItemArray + fCount; |
| + const T* stop = fItemArray; |
| + |
| + while (iter > stop) { |
| + if (*--iter == elem) { |
| + return SkToInt(iter - stop); |
| + } |
| + } |
| + return -1; |
| + } |
| + |
| protected: |
| /** |
| * Creates an empty array that will use the passed storage block until it |