Chromium Code Reviews| 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 GrRedBlackTree_DEFINED | 8 #ifndef GrRedBlackTree_DEFINED |
| 9 #define GrRedBlackTree_DEFINED | 9 #define GrRedBlackTree_DEFINED |
| 10 | 10 |
| 11 #include "GrConfig.h" | 11 #include "GrConfig.h" |
| 12 #include "SkTypes.h" | 12 #include "SkTypes.h" |
| 13 | 13 |
| 14 #include <cstring> | |
|
bsalomon
2014/02/26 21:56:09
I notice in other places we #include string.h and
| |
| 15 | |
| 14 template <typename T> | 16 template <typename T> |
| 15 class GrLess { | 17 class GrLess { |
| 16 public: | 18 public: |
| 17 bool operator()(const T& a, const T& b) const { return a < b; } | 19 bool operator()(const T& a, const T& b) const { return a < b; } |
| 18 }; | 20 }; |
| 19 | 21 |
| 20 template <typename T> | 22 template <typename T> |
| 21 class GrLess<T*> { | 23 class GrLess<T*> { |
| 22 public: | 24 public: |
| 23 bool operator()(const T* a, const T* b) const { return *a < *b; } | 25 bool operator()(const T* a, const T* b) const { return *a < *b; } |
| 24 }; | 26 }; |
| 25 | 27 |
| 28 class GrStrLess { | |
| 29 public: | |
| 30 bool operator()(const char* a, const char* b) const { return std::strcmp(a,b ) < 0; } | |
| 31 }; | |
| 32 | |
| 26 /** | 33 /** |
| 27 * In debug build this will cause full traversals of the tree when the validate | 34 * In debug build this will cause full traversals of the tree when the validate |
| 28 * is called on insert and remove. Useful for debugging but very slow. | 35 * is called on insert and remove. Useful for debugging but very slow. |
| 29 */ | 36 */ |
| 30 #define DEEP_VALIDATE 0 | 37 #define DEEP_VALIDATE 0 |
| 31 | 38 |
| 32 /** | 39 /** |
| 33 * A sorted tree that uses the red-black tree algorithm. Allows duplicate | 40 * A sorted tree that uses the red-black tree algorithm. Allows duplicate |
| 34 * entries. Data is of type T and is compared using functor C. A single C object | 41 * entries. Data is of type T and is compared using functor C. A single C object |
| 35 * will be created and used for all comparisons. | 42 * will be created and used for all comparisons. |
| (...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 934 return validateChildRelationsFailed(); | 941 return validateChildRelationsFailed(); |
| 935 } | 942 } |
| 936 } | 943 } |
| 937 } | 944 } |
| 938 } | 945 } |
| 939 return true; | 946 return true; |
| 940 } | 947 } |
| 941 #endif | 948 #endif |
| 942 | 949 |
| 943 #endif | 950 #endif |
| OLD | NEW |