@@ -66,14 +66,15 @@ julia> searchsorted_interval(Float64[], 1..3)
6666```
6767"""
6868function searchsorted_interval (X, i:: Interval{L, R} ; rev= false ) where {L, R}
69+ ord = Base. Order. ord (< , identity, rev)
6970 if rev === true
70- _searchsorted_begin (X, rightendpoint (i), Val (R); rev ): _searchsorted_end (X, leftendpoint (i), Val (L); rev )
71+ _searchsorted_begin (X, rightendpoint (i), Val (R), ord ): _searchsorted_end (X, leftendpoint (i), Val (L), ord )
7172 else
72- _searchsorted_begin (X, leftendpoint (i), Val (L); rev ): _searchsorted_end (X, rightendpoint (i), Val (R); rev )
73+ _searchsorted_begin (X, leftendpoint (i), Val (L), ord ): _searchsorted_end (X, rightendpoint (i), Val (R), ord )
7374 end
7475end
7576
76- _searchsorted_begin (X, x, :: Val{:closed} ; rev ) = searchsortedfirst (X, x; rev, lt = < )
77- _searchsorted_begin (X, x, :: Val{:open} ; rev ) = searchsortedlast (X, x; rev, lt = < ) + 1
78- _searchsorted_end (X, x, :: Val{:closed} ; rev ) = searchsortedlast (X, x; rev, lt = < )
79- _searchsorted_end (X, x, :: Val{:open} ; rev ) = searchsortedfirst (X, x; rev, lt = < ) - 1
77+ _searchsorted_begin (X, x, :: Val{:closed} , ord ) = searchsortedfirst (X, x, ord )
78+ _searchsorted_begin (X, x, :: Val{:open} , ord ) = searchsortedlast (X, x, ord ) + 1
79+ _searchsorted_end (X, x, :: Val{:closed} , ord ) = searchsortedlast (X, x, ord )
80+ _searchsorted_end (X, x, :: Val{:open} , ord ) = searchsortedfirst (X, x, ord ) - 1
0 commit comments