diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-11-15 19:52:43 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-11-15 19:52:43 +0000 |
| commit | 8938c85eb544b4df3c3d0d4be22c5bd96995e25f (patch) | |
| tree | 0d3bfa8d681c34f8f9cf014dff8e29c626186a8a | |
| parent | 7ade203c6c77cb1c90bee1fa1419bec37fd0ec09 (diff) | |
| download | bcm5719-llvm-8938c85eb544b4df3c3d0d4be22c5bd96995e25f.tar.gz bcm5719-llvm-8938c85eb544b4df3c3d0d4be22c5bd96995e25f.zip | |
add a version of array_pod_sort that takes a custom comparator function.
llvm-svn: 88861
| -rw-r--r-- | llvm/include/llvm/ADT/STLExtras.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h index 6f4769260aa..a8b613307da 100644 --- a/llvm/include/llvm/ADT/STLExtras.h +++ b/llvm/include/llvm/ADT/STLExtras.h @@ -270,6 +270,14 @@ static inline void array_pod_sort(IteratorTy Start, IteratorTy End) { get_array_pad_sort_comparator(*Start)); } +template<class IteratorTy> +static inline void array_pod_sort(IteratorTy Start, IteratorTy End, + int (*Compare)(const void*, const void*)) { + // Don't dereference start iterator of empty sequence. + if (Start == End) return; + qsort(&*Start, End-Start, sizeof(*Start), Compare); +} + } // End llvm namespace #endif |

