@@ -12,8 +12,9 @@ Obtain `getindex(A, I...)` with the guarantee that there is a stored entry at th
12
12
13
13
Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A)`.
14
14
"""
15
- @inline getstoredindex (A:: AbstractArray , I... ) =
16
- @interface interface (A) getstoredindex (A, I... )
15
+ @inline getstoredindex (A:: AbstractArray , I... ) = @interface interface (A) getstoredindex (
16
+ A, I...
17
+ )
17
18
18
19
"""
19
20
getunstoredindex(A::AbstractArray, I...) -> eltype(A)
@@ -25,8 +26,9 @@ instantiated object.
25
26
26
27
Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A)`.
27
28
"""
28
- @inline getunstoredindex (A:: AbstractArray , I... ) =
29
- @interface interface (A) getunstoredindex (A, I... )
29
+ @inline getunstoredindex (A:: AbstractArray , I... ) = @interface interface (A) getunstoredindex (
30
+ A, I...
31
+ )
30
32
31
33
"""
32
34
isstored(A::AbstractArray, I...) -> Bool
@@ -46,8 +48,9 @@ Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A
46
48
47
49
Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(A)`.
48
50
"""
49
- @inline setstoredindex! (A:: AbstractArray , v, I... ) =
50
- @interface interface (A) setstoredindex! (A, v, I... )
51
+ @inline setstoredindex! (A:: AbstractArray , v, I... ) = @interface interface (A) setstoredindex! (
52
+ A, v, I...
53
+ )
51
54
52
55
"""
53
56
setunstoredindex!(A::AbstractArray, v, I...) -> A
@@ -56,8 +59,9 @@ Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(
56
59
57
60
Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(A)`.
58
61
"""
59
- @inline setunstoredindex! (A:: AbstractArray , v, I... ) =
60
- @interface interface (A) setunstoredindex! (A, v, I... )
62
+ @inline setunstoredindex! (A:: AbstractArray , v, I... ) = @interface interface (A) setunstoredindex! (
63
+ A, v, I...
64
+ )
61
65
62
66
# Indices interface
63
67
# -----------------
@@ -150,14 +154,16 @@ for f in (:isstored, :getunstoredindex, :getstoredindex)
150
154
end
151
155
152
156
# errors
153
- $ _f (:: IndexStyle , A:: AbstractArray , I... ) =
154
- error (" `$f ` for $(" $(typeof (A)) " ) with types $(" $(typeof (I)) " ) is not supported" )
155
-
156
- $ error_if_canonical (:: IndexLinear , A:: AbstractArray , :: Int ) =
157
- throw (Base. CanonicalIndexError (" $($ f) " , typeof (A)))
158
- $ error_if_canonical (
159
- :: IndexCartesian , A:: AbstractArray{<:Any,N} , :: Vararg{Int,N}
160
- ) where {N} = throw (Base. CanonicalIndexError (" $($ f) " , typeof (A)))
157
+ $ _f (:: IndexStyle , A:: AbstractArray , I... ) = error (
158
+ " `$f ` for $(" $(typeof (A)) " ) with types $(" $(typeof (I)) " ) is not supported"
159
+ )
160
+
161
+ $ error_if_canonical (:: IndexLinear , A:: AbstractArray , :: Int ) = throw (
162
+ Base. CanonicalIndexError (" $($ f) " , typeof (A))
163
+ )
164
+ $ error_if_canonical (:: IndexCartesian , A:: AbstractArray{<:Any,N} , :: Vararg{Int,N} ) where {N} = throw (
165
+ Base. CanonicalIndexError (" $($ f) " , typeof (A))
166
+ )
161
167
$ error_if_canonical (:: IndexStyle , A:: AbstractArray , :: Any... ) = nothing
162
168
end
163
169
end
@@ -193,14 +199,16 @@ for f! in (:setunstoredindex!, :setstoredindex!)
193
199
end
194
200
195
201
# errors
196
- $ _f! (:: IndexStyle , A:: AbstractArray , I... ) =
197
- error (" `$f! ` for $(" $(typeof (A)) " ) with types $(" $(typeof (I)) " ) is not supported" )
198
-
199
- $ error_if_canonical (:: IndexLinear , A:: AbstractArray , :: Int ) =
200
- throw (Base. CanonicalIndexError (" $($ (string (f!))) " , typeof (A)))
201
- $ error_if_canonical (
202
- :: IndexCartesian , A:: AbstractArray{<:Any,N} , :: Vararg{Int,N}
203
- ) where {N} = throw (Base. CanonicalIndexError (" $($ f!) " , typeof (A)))
202
+ $ _f! (:: IndexStyle , A:: AbstractArray , I... ) = error (
203
+ " `$f! ` for $(" $(typeof (A)) " ) with types $(" $(typeof (I)) " ) is not supported"
204
+ )
205
+
206
+ $ error_if_canonical (:: IndexLinear , A:: AbstractArray , :: Int ) = throw (
207
+ Base. CanonicalIndexError (" $($ (string (f!))) " , typeof (A))
208
+ )
209
+ $ error_if_canonical (:: IndexCartesian , A:: AbstractArray{<:Any,N} , :: Vararg{Int,N} ) where {N} = throw (
210
+ Base. CanonicalIndexError (" $($ f!) " , typeof (A))
211
+ )
204
212
$ error_if_canonical (:: IndexStyle , A:: AbstractArray , :: Any... ) = nothing
205
213
end
206
214
end
@@ -227,14 +235,16 @@ end
227
235
@inline
228
236
return setindex! (A, v, I... )
229
237
end
230
- @interface :: AbstractArrayInterface setunstoredindex! (A:: AbstractArray , v, I:: Int... ) =
231
- error (" setunstoredindex! for $(typeof (A)) is not supported" )
238
+ @interface :: AbstractArrayInterface setunstoredindex! (A:: AbstractArray , v, I:: Int... ) = error (
239
+ " setunstoredindex! for $(typeof (A)) is not supported"
240
+ )
232
241
233
- @interface :: AbstractArrayInterface eachstoredindex (A:: AbstractArray , B:: AbstractArray... ) =
234
- eachstoredindex (IndexStyle (A, B... ), A, B... )
235
- @interface :: AbstractArrayInterface eachstoredindex (
236
- style:: IndexStyle , A:: AbstractArray , B:: AbstractArray...
237
- ) = eachindex (style, A, B... )
242
+ @interface :: AbstractArrayInterface eachstoredindex (A:: AbstractArray , B:: AbstractArray... ) = eachstoredindex (
243
+ IndexStyle (A, B... ), A, B...
244
+ )
245
+ @interface :: AbstractArrayInterface eachstoredindex (style:: IndexStyle , A:: AbstractArray , B:: AbstractArray... ) = eachindex (
246
+ style, A, B...
247
+ )
238
248
239
249
@interface :: AbstractArrayInterface storedvalues (A:: AbstractArray ) = values (A)
240
250
@interface :: AbstractArrayInterface storedpairs (A:: AbstractArray ) = pairs (A)
299
309
end
300
310
301
311
# required:
302
- @interface :: AbstractSparseArrayInterface eachstoredindex (
303
- style :: IndexStyle , A :: AbstractArray
304
- ) = throw ( MethodError (eachstoredindex, Tuple{ typeof (style), typeof (A)}))
312
+ @interface :: AbstractSparseArrayInterface eachstoredindex (style :: IndexStyle , A :: AbstractArray ) = throw (
313
+ MethodError (eachstoredindex, Tuple{ typeof (style), typeof (A)})
314
+ )
305
315
306
316
# derived but may be specialized:
307
317
@interface :: AbstractSparseArrayInterface function eachstoredindex (
@@ -379,8 +389,9 @@ for f! in (:setstoredindex!, :setunstoredindex!)
379
389
end
380
390
end
381
391
382
- @interface :: AbstractSparseArrayInterface storedlength (A:: AbstractArray ) =
383
- length (storedvalues (A))
392
+ @interface :: AbstractSparseArrayInterface storedlength (A:: AbstractArray ) = length (
393
+ storedvalues (A)
394
+ )
384
395
@interface :: AbstractSparseArrayInterface function storedpairs (A:: AbstractArray )
385
396
return Iterators. map (I -> (I => A[I]), eachstoredindex (A))
386
397
end
0 commit comments