2

Is there something similar to bsearch built in, that returns the immediately smaller element if the same element is not present and NULL only if the element is already smaller than all other elements. This would require the user to check if the return value's key is same as the function argument, but it would be very useful in its own right. Thanks.

alk
  • 69,737
  • 10
  • 105
  • 255
0fnt
  • 8,211
  • 9
  • 45
  • 62
  • I should have noted it. Implementation is not an issue for me, its just that I wonder if there is just a line of code that would do the needful for me. Anyway, doesn't look like its possible. – 0fnt Nov 19 '10 at 14:36

2 Answers2

1

It doesn't exist the way you want it. You would need to implement it.

Shamim Hafiz - MSFT
  • 21,454
  • 43
  • 116
  • 176
0

As far as I can say there is no such function in the standard library. But it should not be to hard to do this on your own or find a library.

frast
  • 2,700
  • 1
  • 25
  • 34