SHBinarySearchForRange for iOS

A simple library to perform binary search to find the nearest double/float value from a double/float array for a given double/float.

Overview

This cocoapod helps to find the nearest ceiling double/float value from a double/float array by performing a binary search operation.

Requirements
  • ARC
  • iOS8
Installation

SHBinarySearchForRange is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "SHBinarySearchForRange"

Usage

``` #import "SHBinarySearchForRange.h"

NSArray *array = @[@0.12f, @0.23f, @0.3f, @0.345f, @0.967f, @1.0f];

SHBinarySearchForRange *binarySearch = [[SHBinarySearchForRange alloc] initWithValues:array];

NSInteger index = [binarySearch indexOfClosestCeilingForSearchItem:10.67575f];

NSNumber *valAtIndex = [array objectAtIndex:index];

NSLog(@"Value close to range: %f", valAtIndex.doubleValue); ```

Share feedbacks and ideas to improve this project, I would love to hear them out. I would also greatly appreciate if you follow me on @shabib_hossain.

License: MIT

Language: Objective-C

Platform: iOS

Sponsored with ❤️ by Instabug
Instabug: Understand how your app is doing with real-time contextual insights from your users
Instabug

Get all the logs you need and fix bugs, crashes, and other issues in minutes instead of days. With Instabug you will automatically receive device data, network logs, and reproduction steps with every bug and crash report. It only takes a line of code to integrate and is perfect for teams that are now working remotely. See more detailed features comparison and try Instabug for free here.