OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 SkTSet_DEFINED | 8 #ifndef SkTSet_DEFINED |
9 #define SkTSet_DEFINED | 9 #define SkTSet_DEFINED |
10 | 10 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 return false; | 284 return false; |
285 } | 285 } |
286 if (fOrderedArray->count() == 0) { | 286 if (fOrderedArray->count() == 0) { |
287 return true; | 287 return true; |
288 } | 288 } |
289 | 289 |
290 // Copy and sort fOrderedArray, then compare to fSetArray. | 290 // Copy and sort fOrderedArray, then compare to fSetArray. |
291 // A O(n log n) algorithm is necessary as O(n^2) will choke some GMs. | 291 // A O(n log n) algorithm is necessary as O(n^2) will choke some GMs. |
292 SkAutoMalloc sortedArray(fOrderedArray->bytes()); | 292 SkAutoMalloc sortedArray(fOrderedArray->bytes()); |
293 T* sortedBase = reinterpret_cast<T*>(sortedArray.get()); | 293 T* sortedBase = reinterpret_cast<T*>(sortedArray.get()); |
294 size_t count = fOrderedArray->count(); | 294 int count = fOrderedArray->count(); |
295 fOrderedArray->copyRange(sortedBase, 0, count); | 295 fOrderedArray->copyRange(sortedBase, 0, count); |
296 | 296 |
297 SkTQSort<T>(sortedBase, sortedBase + count - 1); | 297 SkTQSort<T>(sortedBase, sortedBase + count - 1); |
298 | 298 |
299 for (size_t i = 0; i < count; ++i) { | 299 for (int i = 0; i < count; ++i) { |
300 if (sortedBase[i] != (*fSetArray)[i]) { | 300 if (sortedBase[i] != (*fSetArray)[i]) { |
301 return false; | 301 return false; |
302 } | 302 } |
303 } | 303 } |
304 | 304 |
305 return true; | 305 return true; |
306 } | 306 } |
307 #endif | 307 #endif |
308 | 308 |
309 private: | 309 private: |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 } else { | 347 } else { |
348 *posToInsertSorted = iMin + 1; | 348 *posToInsertSorted = iMin + 1; |
349 } | 349 } |
350 } | 350 } |
351 | 351 |
352 return -1; | 352 return -1; |
353 } | 353 } |
354 }; | 354 }; |
355 | 355 |
356 #endif | 356 #endif |
OLD | NEW |