Re #8033. Change to a linear search to a binary one.

And use a standard algorithm instead of home-brewing it.
Re #8033. Update comments.
Merge branch 'feature/8033_getbinindex_binary_search' into develop