]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a median_int32 and find_nth_int32
authorNick Mathewson <nickm@torproject.org>
Tue, 15 Sep 2009 03:14:03 +0000 (23:14 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 15 Sep 2009 03:21:52 +0000 (23:21 -0400)
src/common/container.c
src/common/container.h

index c649787c0ffb9a6eb9f0a7b1df9b8ca60caa3ad5..12ac2527e91a3f404f048d81915b62b8925ce8ee 100644 (file)
@@ -1220,6 +1220,7 @@ IMPLEMENT_ORDER_FUNC(find_nth_int, int)
 IMPLEMENT_ORDER_FUNC(find_nth_time, time_t)
 IMPLEMENT_ORDER_FUNC(find_nth_double, double)
 IMPLEMENT_ORDER_FUNC(find_nth_uint32, uint32_t)
+IMPLEMENT_ORDER_FUNC(find_nth_int32, int32_t)
 IMPLEMENT_ORDER_FUNC(find_nth_long, long)
 
 /** Return a newly allocated digestset_t, optimized to hold a total of
index e6265524677c1674c1023fe1130e7e6f1ce33d66..4495a7a27318049466f72f09d41b0890bcd08726 100644 (file)
@@ -627,6 +627,7 @@ void digestset_free(digestset_t* set);
 int find_nth_int(int *array, int n_elements, int nth);
 time_t find_nth_time(time_t *array, int n_elements, int nth);
 double find_nth_double(double *array, int n_elements, int nth);
+int32_t find_nth_int32(int32_t *array, int n_elements, int nth);
 uint32_t find_nth_uint32(uint32_t *array, int n_elements, int nth);
 long find_nth_long(long *array, int n_elements, int nth);
 static INLINE int
@@ -649,6 +650,11 @@ median_uint32(uint32_t *array, int n_elements)
 {
   return find_nth_uint32(array, n_elements, (n_elements-1)/2);
 }
+static INLINE int32_t
+median_int32(int32_t *array, int n_elements)
+{
+  return find_nth_int32(array, n_elements, (n_elements-1)/2);
+}
 static INLINE long
 median_long(long *array, int n_elements)
 {