Index: src/libcfa/stdlib
===================================================================
--- src/libcfa/stdlib	(revision 853451bf01109989a343f4c8c712cf9eecae442c)
+++ src/libcfa/stdlib	(revision 93cdd5c0be264ba634992d1544795d31af46143b)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:12:35 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Dec 28 18:43:12 2017
-// Update Count     : 277
+// Last Modified On : Mon Jan  1 17:35:43 2018
+// Update Count     : 291
 //
 
@@ -186,17 +186,44 @@
 
 forall( otype E | { int ?<?( E, E ); } )
-E * bsearch( E key, const E * arr, size_t dim );
-
-forall( otype E | { int ?<?( E, E ); } )
-unsigned int bsearch( E key, const E * arr, size_t dim );
-
-forall( otype K, otype E | { int ?<?( K, K ); K getKey( E & ); } )
-E * bsearch( K key, const E * arr, size_t dim );
-
-forall( otype K, otype E | { int ?<?( K, K ); K getKey( E & ); } )
-unsigned int bsearch( K key, const E * arr, size_t dim );
-
-forall( otype E | { int ?<?( E, E ); } )
-void qsort( E * arr, size_t dim );
+E * bsearch( E key, const E * vals, size_t dim );
+
+forall( otype E | { int ?<?( E, E ); } )
+size_t bsearch( E key, const E * vals, size_t dim );
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+E * bsearch( K key, const E * vals, size_t dim );
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+size_t bsearch( K key, const E * vals, size_t dim );
+
+
+forall( otype E | { int ?<?( E, E ); } )
+E * bsearchl( E key, const E * vals, size_t dim );
+
+forall( otype E | { int ?<?( E, E ); } )
+size_t bsearchl( E key, const E * vals, size_t dim );
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+E * bsearchl( K key, const E * vals, size_t dim );
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+size_t bsearchl( K key, const E * vals, size_t dim );
+
+
+forall( otype E | { int ?<?( E, E ); } )
+E * bsearchu( E key, const E * vals, size_t dim );
+
+forall( otype E | { int ?<?( E, E ); } )
+size_t bsearchu( E key, const E * vals, size_t dim );
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+E * bsearchu( K key, const E * vals, size_t dim );
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+size_t bsearchu( K key, const E * vals, size_t dim );
+
+
+forall( otype E | { int ?<?( E, E ); } )
+void qsort( E * vals, size_t dim );
 
 //---------------------------------------
Index: src/libcfa/stdlib.c
===================================================================
--- src/libcfa/stdlib.c	(revision 853451bf01109989a343f4c8c712cf9eecae442c)
+++ src/libcfa/stdlib.c	(revision 93cdd5c0be264ba634992d1544795d31af46143b)
@@ -10,6 +10,6 @@
 // Created On       : Thu Jan 28 17:10:29 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Dec 28 18:43:16 2017
-// Update Count     : 378
+// Last Modified On : Mon Jan  1 19:03:16 2018
+// Update Count     : 437
 //
 
@@ -129,31 +129,120 @@
 
 forall( otype E | { int ?<?( E, E ); } )
-E * bsearch( E key, const E * arr, size_t dim ) {
-	int comp( const void * t1, const void * t2 ) { return *(E *)t1 < *(E *)t2 ? -1 : *(E *)t2 < *(E *)t1 ? 1 : 0; }
-	return (E *)bsearch( &key, arr, dim, sizeof(E), comp );
-} // bsearch
-
-forall( otype E | { int ?<?( E, E ); } )
-unsigned int bsearch( E key, const E * arr, size_t dim ) {
-	E * result = bsearch( key, arr, dim );
-	return result ? result - arr : dim;					// pointer subtraction includes sizeof(E)
-} // bsearch
-
-forall( otype K, otype E | { int ?<?( K, K ); K getKey( E & ); } )
-E * bsearch( K key, const E * arr, size_t dim ) {
-	int comp( const void * t1, const void * t2 ) { return *(K *)t1 < getKey( *(E *)t2 ) ? -1 : getKey( *(E *)t2 ) < *(K *)t1 ? 1 : 0; }
-	return (E *)bsearch( &key, arr, dim, sizeof(E), comp );
-} // bsearch
-
-forall( otype K, otype E | { int ?<?( K, K ); K getKey( E & ); } )
-unsigned int bsearch( K key, const E * arr, size_t dim ) {
-	E * result = bsearch( key, arr, dim );
-	return result ? result - arr : dim;					// pointer subtraction includes sizeof(E)
-} // bsearch
-
-forall( otype E | { int ?<?( E, E ); } )
-void qsort( E * arr, size_t dim ) {
-	int comp( const void * t1, const void * t2 ) { return *(E *)t1 < *(E *)t2 ? -1 : *(E *)t2 < *(E *)t1 ? 1 : 0; }
-	qsort( arr, dim, sizeof(E), comp );
+E * bsearch( E key, const E * vals, size_t dim ) {
+	int cmp( const void * t1, const void * t2 ) {
+		return *(E *)t1 < *(E *)t2 ? -1 : *(E *)t2 < *(E *)t1 ? 1 : 0;
+	} // cmp
+	return (E *)bsearch( &key, vals, dim, sizeof(E), cmp );
+} // bsearch
+
+forall( otype E | { int ?<?( E, E ); } )
+size_t bsearch( E key, const E * vals, size_t dim ) {
+	E * result = bsearch( key, vals, dim );
+	return result ? result - vals : dim;				// pointer subtraction includes sizeof(E)
+} // bsearch
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+E * bsearch( K key, const E * vals, size_t dim ) {
+	int cmp( const void * t1, const void * t2 ) {
+		return *(K *)t1 < getKey( *(E *)t2 ) ? -1 : getKey( *(E *)t2 ) < *(K *)t1 ? 1 : 0;
+	} // cmp
+	return (E *)bsearch( &key, vals, dim, sizeof(E), cmp );
+} // bsearch
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+size_t bsearch( K key, const E * vals, size_t dim ) {
+	E * result = bsearch( key, vals, dim );
+	return result ? result - vals : dim;				// pointer subtraction includes sizeof(E)
+} // bsearch
+
+
+forall( otype E | { int ?<?( E, E ); } )
+size_t bsearchl( E key, const E * vals, size_t dim ) {
+	size_t l = 0, m, h = dim;
+	while ( l < h ) {
+		m = (l + h) / 2;
+		if ( (E &)(vals[m]) < key ) {					// cast away const
+			l = m + 1;
+		} else {
+			h = m;
+		} // if
+	} // while
+	return l;
+} // bsearchl
+
+forall( otype E | { int ?<?( E, E ); } )
+E * bsearchl( E key, const E * vals, size_t dim ) {
+	size_t posn = bsearchl( key, vals, dim );
+	return (E *)(&vals[posn]);							// cast away const
+} // bsearchl
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+size_t bsearchl( K key, const E * vals, size_t dim ) {
+	size_t l = 0, m, h = dim;
+	while ( l < h ) {
+		m = (l + h) / 2;
+		if ( getKey( vals[m] ) < key ) {
+			l = m + 1;
+		} else {
+			h = m;
+		} // if
+	} // while
+	return l;
+} // bsearchl
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+E * bsearchl( K key, const E * vals, size_t dim ) {
+	size_t posn = bsearchl( key, vals, dim );
+	return (E *)(&vals[posn]);							// cast away const
+} // bsearchl
+
+
+forall( otype E | { int ?<?( E, E ); } )
+size_t bsearchu( E key, const E * vals, size_t dim ) {
+	size_t l = 0, m, h = dim;
+	while ( l < h ) {
+		m = (l + h) / 2;
+		if ( ! ( key < (E &)(vals[m]) ) ) {				// cast away const
+			l = m + 1;
+		} else {
+			h = m;
+		} // if
+	} // while
+	return l;
+} // bsearchu
+
+forall( otype E | { int ?<?( E, E ); } )
+E * bsearchu( E key, const E * vals, size_t dim ) {
+	size_t posn = bsearchu( key, vals, dim );
+	return (E *)(&vals[posn]);
+} // bsearchu
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+size_t bsearchu( K key, const E * vals, size_t dim ) {
+	size_t l = 0, m, h = dim;
+	while ( l < h ) {
+		m = (l + h) / 2;
+		if ( ! ( key < getKey( vals[m] ) ) ) {
+			l = m + 1;
+		} else {
+			h = m;
+		} // if
+	} // while
+	return l;
+} // bsearchu
+
+forall( otype K, otype E | { int ?<?( K, K ); K getKey( const E & ); } )
+E * bsearchu( K key, const E * vals, size_t dim ) {
+	size_t posn = bsearchu( key, vals, dim );
+	return (E *)(&vals[posn]);
+} // bsearchu
+
+
+forall( otype E | { int ?<?( E, E ); } )
+void qsort( E * vals, size_t dim ) {
+	int cmp( const void * t1, const void * t2 ) {
+		return *(E *)t1 < *(E *)t2 ? -1 : *(E *)t2 < *(E *)t1 ? 1 : 0;
+	} // cmp
+	qsort( vals, dim, sizeof(E), cmp );
 } // qsort
 
Index: src/tests/searchsort.c
===================================================================
--- src/tests/searchsort.c	(revision 853451bf01109989a343f4c8c712cf9eecae442c)
+++ src/tests/searchsort.c	(revision 93cdd5c0be264ba634992d1544795d31af46143b)
@@ -10,6 +10,6 @@
 // Created On       : Thu Feb  4 18:17:50 2016
 // Last Modified By : Peter A. Buhr
-// Last Modified On : Thu Dec 28 18:48:10 2017
-// Update Count     : 99
+// Last Modified On : Tue Jan  2 08:01:17 2018
+// Update Count     : 100
 // 
 
@@ -128,5 +128,5 @@
 	sout | endl | endl;
 	{
-		unsigned int getKey( S & s ) { return s.j; }
+		unsigned int getKey( const S & s ) { return s.j; }
 		for ( unsigned int i = 0; i < size; i += 1 ) {
 			sout | sarr[i] | ", ";
