From: Chris Lattner Date: Sun, 15 Nov 2009 19:52:43 +0000 (+0000) Subject: add a version of array_pod_sort that takes a custom comparator function. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9806f833a6697b835f1c795a1bd2f26a84d49d3c;p=oota-llvm.git add a version of array_pod_sort that takes a custom comparator function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@88861 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 6f4769260aa..a8b613307da 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/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 +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