improve contains() for ranges and add searchsorted* for ranges. fix #2877

cherry-pick of 6f814674a50fcfdd2c9c69743581b3f00e323020 and 9cc671d4f84e10bbdb941fcd34126e3d31ac6594