add a version of array_pod_sort that takes a custom comparator function.
authorChris Lattner <sabre@nondot.org>
Sun, 15 Nov 2009 19:52:43 +0000 (19:52 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 15 Nov 2009 19:52:43 +0000 (19:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88861 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/STLExtras.h

index 6f4769260aa9063ca23991081f6d2305faf167d3..a8b613307da1f2d302c83fe39bea5866c16334f2 100644 (file)
@@ -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