99
99
100
100
mean (d:: AbstractInterval ) = (leftendpoint (d) + rightendpoint (d))/ 2
101
101
102
- issubset (A:: AbstractInterval , B:: AbstractInterval ) = ((leftendpoint (A) in B) && (rightendpoint (A) in B)) || isempty (A)
103
- ⊇ (A:: AbstractInterval , B:: AbstractInterval ) = issubset (B, A)
104
- if VERSION < v " 1.1.0-DEV.123"
105
- issubset (x, B:: AbstractInterval ) = issubset (convert (AbstractInterval, x), B)
106
- end
107
-
108
102
"""
109
103
w = width(iv)
110
104
@@ -143,22 +137,49 @@ in(::Missing, I::TypedEndpointsInterval{:open,:open}) = !isempty(I) && missing
143
137
in (:: Missing , I:: TypedEndpointsInterval{:closed,:open} ) = ! isempty (I) && missing
144
138
in (:: Missing , I:: TypedEndpointsInterval{:open,:closed} ) = ! isempty (I) && missing
145
139
146
- in (a:: AbstractInterval , b:: TypedEndpointsInterval{:closed,:closed} ) =
140
+ # The code below can be defined as
141
+ # ```
142
+ # function in(a::AbstractInterval, b::AbstractInterval)
143
+ # Base.depwarn("`in(a::AbstractInterval, b::AbstractInterval)` (equivalently, `a ∈ b`) is deprecated in favor of `issubset(a, b)` (equivalently, `a ⊆ b`). Note that the behavior for empty intervals is also changing.", :in)
144
+ # return in_deprecation(a, b)
145
+ # end
146
+ # ```
147
+ # but that makes ambiguity definition.
148
+ function in (a:: AbstractInterval , b:: TypedEndpointsInterval{:closed,:closed} )
149
+ Base. depwarn (" `in(a::AbstractInterval, b::AbstractInterval)` (equivalently, `a ∈ b`) is deprecated in favor of `issubset(a, b)` (equivalently, `a ⊆ b`). Note that the behavior for empty intervals is also changing." , :in )
150
+ return in_deprecation (a, b)
151
+ end
152
+ function in (a:: AbstractInterval , b:: TypedEndpointsInterval{:open,:open} )
153
+ Base. depwarn (" `in(a::AbstractInterval, b::AbstractInterval)` (equivalently, `a ∈ b`) is deprecated in favor of `issubset(a, b)` (equivalently, `a ⊆ b`). Note that the behavior for empty intervals is also changing." , :in )
154
+ return in_deprecation (a, b)
155
+ end
156
+ function in (a:: AbstractInterval , b:: TypedEndpointsInterval{:closed,:open} )
157
+ Base. depwarn (" `in(a::AbstractInterval, b::AbstractInterval)` (equivalently, `a ∈ b`) is deprecated in favor of `issubset(a, b)` (equivalently, `a ⊆ b`). Note that the behavior for empty intervals is also changing." , :in )
158
+ return in_deprecation (a, b)
159
+ end
160
+ function in (a:: AbstractInterval , b:: TypedEndpointsInterval{:open,:closed} )
161
+ Base. depwarn (" `in(a::AbstractInterval, b::AbstractInterval)` (equivalently, `a ∈ b`) is deprecated in favor of `issubset(a, b)` (equivalently, `a ⊆ b`). Note that the behavior for empty intervals is also changing." , :in )
162
+ return in_deprecation (a, b)
163
+ end
164
+
165
+ in_deprecation (a:: AbstractInterval , b:: TypedEndpointsInterval{:closed,:closed} ) =
147
166
(leftendpoint (a) ≥ leftendpoint (b)) & (rightendpoint (a) ≤ rightendpoint (b))
148
- in (a:: TypedEndpointsInterval{:open,:open} , b:: TypedEndpointsInterval{:open,:open} ) =
167
+ in_deprecation (a:: TypedEndpointsInterval{:open,:open} , b:: TypedEndpointsInterval{:open,:open} ) =
149
168
(leftendpoint (a) ≥ leftendpoint (b)) & (rightendpoint (a) ≤ rightendpoint (b))
150
- in (a:: TypedEndpointsInterval{:closed,:open} , b:: TypedEndpointsInterval{:open,:open} ) =
169
+ in_deprecation (a:: TypedEndpointsInterval{:closed,:open} , b:: TypedEndpointsInterval{:open,:open} ) =
151
170
(leftendpoint (a) > leftendpoint (b)) & (rightendpoint (a) ≤ rightendpoint (b))
152
- in (a:: TypedEndpointsInterval{:open,:closed} , b:: TypedEndpointsInterval{:open,:open} ) =
171
+ in_deprecation (a:: TypedEndpointsInterval{:open,:closed} , b:: TypedEndpointsInterval{:open,:open} ) =
153
172
(leftendpoint (a) ≥ leftendpoint (b)) & (rightendpoint (a) < rightendpoint (b))
154
- in (a:: TypedEndpointsInterval{:closed,:closed} , b:: TypedEndpointsInterval{:open,:open} ) =
173
+ in_deprecation (a:: TypedEndpointsInterval{:closed,:closed} , b:: TypedEndpointsInterval{:open,:open} ) =
155
174
(leftendpoint (a) > leftendpoint (b)) & (rightendpoint (a) < rightendpoint (b))
156
- in (a:: TypedEndpointsInterval{:closed} , b:: TypedEndpointsInterval{:open,:closed} ) =
175
+ in_deprecation (a:: TypedEndpointsInterval{:closed} , b:: TypedEndpointsInterval{:open,:closed} ) =
157
176
(leftendpoint (a) > leftendpoint (b)) & (rightendpoint (a) ≤ rightendpoint (b))
158
- in (a:: TypedEndpointsInterval{:open} , b:: TypedEndpointsInterval{:open,:closed} ) =
177
+ in_deprecation (a:: TypedEndpointsInterval{:open} , b:: TypedEndpointsInterval{:open,:closed} ) =
178
+ (leftendpoint (a) ≥ leftendpoint (b)) & (rightendpoint (a) ≤ rightendpoint (b))
179
+ in_deprecation (a:: TypedEndpointsInterval{L,:closed} , b:: TypedEndpointsInterval{:closed,:open} ) where L =
180
+ (leftendpoint (a) ≥ leftendpoint (b)) & (rightendpoint (a) < rightendpoint (b))
181
+ in_deprecation (a:: TypedEndpointsInterval{L,:open} , b:: TypedEndpointsInterval{:closed,:open} ) where L =
159
182
(leftendpoint (a) ≥ leftendpoint (b)) & (rightendpoint (a) ≤ rightendpoint (b))
160
- in (a:: TypedEndpointsInterval{L,:closed} , b:: TypedEndpointsInterval{:closed,:open} ) where L = (leftendpoint (a) ≥ leftendpoint (b)) & (rightendpoint (a) < rightendpoint (b))
161
- in (a:: TypedEndpointsInterval{L,:open} , b:: TypedEndpointsInterval{:closed,:open} ) where L = (leftendpoint (a) ≥ leftendpoint (b)) & (rightendpoint (a) ≤ rightendpoint (b))
162
183
163
184
isempty (A:: TypedEndpointsInterval{:closed,:closed} ) = leftendpoint (A) > rightendpoint (A)
164
185
isempty (A:: TypedEndpointsInterval ) = leftendpoint (A) ≥ rightendpoint (A)
@@ -169,6 +190,32 @@ isequal(A::TypedEndpointsInterval, B::TypedEndpointsInterval) = isempty(A) & ise
169
190
== (A:: TypedEndpointsInterval{L,R} , B:: TypedEndpointsInterval{L,R} ) where {L,R} = (leftendpoint (A) == leftendpoint (B) && rightendpoint (A) == rightendpoint (B)) || (isempty (A) && isempty (B))
170
191
== (A:: TypedEndpointsInterval , B:: TypedEndpointsInterval ) = isempty (A) && isempty (B)
171
192
193
+ function issubset (A:: TypedEndpointsInterval , B:: TypedEndpointsInterval )
194
+ Al, Ar = endpoints (A)
195
+ Bl, Br = endpoints (B)
196
+ return isempty (A) | ( (Bl ≤ Al) & (Ar ≤ Br) )
197
+ end
198
+ function issubset (A:: TypedEndpointsInterval{:closed,R1} where R1, B:: TypedEndpointsInterval{:open,R2} where R2)
199
+ Al, Ar = endpoints (A)
200
+ Bl, Br = endpoints (B)
201
+ return isempty (A) | ( (Bl < Al) & (Ar ≤ Br) )
202
+ end
203
+ function issubset (A:: TypedEndpointsInterval{L1,:closed} where L1, B:: TypedEndpointsInterval{L2,:open} where L2)
204
+ Al, Ar = endpoints (A)
205
+ Bl, Br = endpoints (B)
206
+ return isempty (A) | ( (Bl ≤ Al) & (Ar < Br) )
207
+ end
208
+ function issubset (A:: TypedEndpointsInterval{:closed,:closed} , B:: TypedEndpointsInterval{:open,:open} )
209
+ Al, Ar = endpoints (A)
210
+ Bl, Br = endpoints (B)
211
+ return isempty (A) | ( (Bl < Al) & (Ar < Br) )
212
+ end
213
+
214
+ ⊇ (A:: AbstractInterval , B:: AbstractInterval ) = issubset (B, A)
215
+ if VERSION < v " 1.1.0-DEV.123"
216
+ issubset (x, B:: AbstractInterval ) = issubset (convert (AbstractInterval, x), B)
217
+ end
218
+
172
219
const _interval_hash = UInt == UInt64 ? 0x1588c274e0a33ad4 : 0x1e3f7252
173
220
174
221
hash (I:: TypedEndpointsInterval , h:: UInt ) = hash (leftendpoint (I), hash (rightendpoint (I), hash (_interval_hash, h)))
0 commit comments