Added generic implementation for BinarySearch.