[llvm-commits] [llvm] r88861 - /llvm/trunk/include/llvm/ADT/STLExtras.h
Chris Lattner
sabre at nondot.org
Sun Nov 15 11:52:44 PST 2009
Author: lattner
Date: Sun Nov 15 13:52:43 2009
New Revision: 88861
URL: http://llvm.org/viewvc/llvm-project?rev=88861&view=rev
Log:
add a version of array_pod_sort that takes a custom comparator function.
Modified:
llvm/trunk/include/llvm/ADT/STLExtras.h
Modified: llvm/trunk/include/llvm/ADT/STLExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/STLExtras.h?rev=88861&r1=88860&r2=88861&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/STLExtras.h (original)
+++ llvm/trunk/include/llvm/ADT/STLExtras.h Sun Nov 15 13:52:43 2009
@@ -270,6 +270,14 @@
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
More information about the llvm-commits
mailing list