OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkTArray_DEFINED | 8 #ifndef SkTArray_DEFINED |
9 #define SkTArray_DEFINED | 9 #define SkTArray_DEFINED |
10 | 10 |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 return false; | 357 return false; |
358 } | 358 } |
359 } | 359 } |
360 return true; | 360 return true; |
361 } | 361 } |
362 | 362 |
363 bool operator!=(const SkTArray<T, MEM_COPY>& right) const { | 363 bool operator!=(const SkTArray<T, MEM_COPY>& right) const { |
364 return !(*this == right); | 364 return !(*this == right); |
365 } | 365 } |
366 | 366 |
| 367 int find(const T& elem) const { |
| 368 const T* iter = fItemArray; |
| 369 const T* stop = fItemArray + fCount; |
| 370 |
| 371 for (; iter < stop; iter++) { |
| 372 if (*iter == elem) { |
| 373 return SkToInt(iter - fItemArray); |
| 374 } |
| 375 } |
| 376 return -1; |
| 377 } |
| 378 |
| 379 int rfind(const T& elem) const { |
| 380 const T* iter = fItemArray + fCount; |
| 381 const T* stop = fItemArray; |
| 382 |
| 383 while (iter > stop) { |
| 384 if (*--iter == elem) { |
| 385 return SkToInt(iter - stop); |
| 386 } |
| 387 } |
| 388 return -1; |
| 389 } |
| 390 |
367 protected: | 391 protected: |
368 /** | 392 /** |
369 * Creates an empty array that will use the passed storage block until it | 393 * Creates an empty array that will use the passed storage block until it |
370 * is insufficiently large to hold the entire array. | 394 * is insufficiently large to hold the entire array. |
371 */ | 395 */ |
372 template <int N> | 396 template <int N> |
373 SkTArray(SkAlignedSTStorage<N,T>* storage) { | 397 SkTArray(SkAlignedSTStorage<N,T>* storage) { |
374 this->init(NULL, 0, storage->get(), N); | 398 this->init(NULL, 0, storage->get(), N); |
375 } | 399 } |
376 | 400 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 SkSTArray& operator= (const INHERITED& array) { | 564 SkSTArray& operator= (const INHERITED& array) { |
541 INHERITED::operator=(array); | 565 INHERITED::operator=(array); |
542 return *this; | 566 return *this; |
543 } | 567 } |
544 | 568 |
545 private: | 569 private: |
546 SkAlignedSTStorage<N,T> fStorage; | 570 SkAlignedSTStorage<N,T> fStorage; |
547 }; | 571 }; |
548 | 572 |
549 #endif | 573 #endif |
OLD | NEW |