| OLD | NEW |
| 1 | |
| 2 /* | 1 /* |
| 3 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
| 4 * | 3 * |
| 5 * 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 |
| 6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 7 */ | 6 */ |
| 8 | 7 |
| 9 | |
| 10 | |
| 11 #ifndef GrTBSearch_DEFINED | 8 #ifndef GrTBSearch_DEFINED |
| 12 #define GrTBSearch_DEFINED | 9 #define GrTBSearch_DEFINED |
| 13 | 10 |
| 11 #include "SkTypes.h" |
| 12 |
| 14 template <typename ELEM, typename KEY> | 13 template <typename ELEM, typename KEY> |
| 15 int GrTBSearch(const ELEM array[], int count, KEY target) { | 14 int GrTBSearch(const ELEM array[], int count, KEY target) { |
| 16 SkASSERT(count >= 0); | 15 SkASSERT(count >= 0); |
| 17 if (0 == count) { | 16 if (0 == count) { |
| 18 // we should insert it at 0 | 17 // we should insert it at 0 |
| 19 return ~0; | 18 return ~0; |
| 20 } | 19 } |
| 21 | 20 |
| 22 int high = count - 1; | 21 int high = count - 1; |
| 23 int low = 0; | 22 int low = 0; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 36 } | 35 } |
| 37 | 36 |
| 38 // now return the ~ of where we should insert it | 37 // now return the ~ of where we should insert it |
| 39 if (LT(array[high], target)) { | 38 if (LT(array[high], target)) { |
| 40 high += 1; | 39 high += 1; |
| 41 } | 40 } |
| 42 return ~high; | 41 return ~high; |
| 43 } | 42 } |
| 44 | 43 |
| 45 #endif | 44 #endif |
| OLD | NEW |