@@ -12,8 +12,9 @@ Obtain `getindex(A, I...)` with the guarantee that there is a stored entry at th
1212
1313Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A)`.
1414"""
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+ )
1718
1819"""
1920 getunstoredindex(A::AbstractArray, I...) -> eltype(A)
@@ -25,8 +26,9 @@ instantiated object.
2526
2627Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A)`.
2728"""
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+ )
3032
3133"""
3234 isstored(A::AbstractArray, I...) -> Bool
@@ -46,8 +48,9 @@ Similar to `Base.getindex`, new definitions should be in line with `IndexStyle(A
4648
4749Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(A)`.
4850"""
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+ )
5154
5255"""
5356 setunstoredindex!(A::AbstractArray, v, I...) -> A
@@ -56,8 +59,9 @@ Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(
5659
5760Similar to `Base.setindex!`, new definitions should be in line with `IndexStyle(A)`.
5861"""
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+ )
6165
6266# Indices interface
6367# -----------------
@@ -150,14 +154,16 @@ for f in (:isstored, :getunstoredindex, :getstoredindex)
150154 end
151155
152156 # 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+ )
161167 $ error_if_canonical (:: IndexStyle , A:: AbstractArray , :: Any... ) = nothing
162168 end
163169end
@@ -193,14 +199,16 @@ for f! in (:setunstoredindex!, :setstoredindex!)
193199 end
194200
195201 # 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+ )
204212 $ error_if_canonical (:: IndexStyle , A:: AbstractArray , :: Any... ) = nothing
205213 end
206214end
@@ -227,14 +235,16 @@ end
227235 @inline
228236 return setindex! (A, v, I... )
229237end
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+ )
232241
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+ )
238248
239249@interface :: AbstractArrayInterface storedvalues (A:: AbstractArray ) = values (A)
240250@interface :: AbstractArrayInterface storedpairs (A:: AbstractArray ) = pairs (A)
299309end
300310
301311# 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+ )
305315
306316# derived but may be specialized:
307317@interface :: AbstractSparseArrayInterface function eachstoredindex (
@@ -379,8 +389,9 @@ for f! in (:setstoredindex!, :setunstoredindex!)
379389 end
380390end
381391
382- @interface :: AbstractSparseArrayInterface storedlength (A:: AbstractArray ) =
383- length (storedvalues (A))
392+ @interface :: AbstractSparseArrayInterface storedlength (A:: AbstractArray ) = length (
393+ storedvalues (A)
394+ )
384395@interface :: AbstractSparseArrayInterface function storedpairs (A:: AbstractArray )
385396 return Iterators. map (I -> (I => A[I]), eachstoredindex (A))
386397end
0 commit comments