@@ -160,13 +160,35 @@ end
160
160
# ## Special handling for AbstractRange
161
161
162
162
const OffsetRange{T} = OffsetArray{T,1 ,<: AbstractRange{T} }
163
+ const IIUR = IdentityUnitRange{S} where S<: AbstractUnitRange{T} where T<: Integer
163
164
164
165
Base. step (a:: OffsetRange ) = step (parent (a))
165
166
166
167
Base. getindex (a:: OffsetRange , r:: OffsetRange ) = OffsetArray (a[parent (r)], r. offsets)
167
168
Base. getindex (a:: OffsetRange , r:: AbstractRange ) = a. parent[r .- a. offsets[1 ]]
168
169
Base. getindex (a:: AbstractRange , r:: OffsetRange ) = OffsetArray (a[parent (r)], r. offsets)
169
170
171
+ @inline @propagate_inbounds Base. getindex (r:: UnitRange , s:: IIUR ) =
172
+ OffsetArray (r[s. indices], s)
173
+
174
+ @inline @propagate_inbounds Base. getindex (r:: StepRange , s:: IIUR ) =
175
+ OffsetArray (r[s. indices], s)
176
+
177
+ @inline @propagate_inbounds Base. getindex (r:: StepRangeLen{T,<:Base.TwicePrecision,<:Base.TwicePrecision} , s:: IIUR ) where T =
178
+ OffsetArray (r[s. indices], s)
179
+ @inline @propagate_inbounds Base. getindex (r:: StepRangeLen{T} , s:: IIUR ) where {T} =
180
+ OffsetArray (r[s. indices], s)
181
+
182
+ @inline @propagate_inbounds Base. getindex (r:: LinRange , s:: IIUR ) =
183
+ OffsetArray (r[s. indices], s)
184
+
185
+ function Base. show (io:: IO , r:: OffsetRange )
186
+ show (io, r. parent)
187
+ o = r. offsets[1 ]
188
+ print (io, " with indices " , o+ 1 : o+ length (r))
189
+ end
190
+ Base. show (io:: IO , :: MIME"text/plain" , r:: OffsetRange ) = show (io, r)
191
+
170
192
# ## Convenience functions ###
171
193
172
194
Base. fill (x, inds:: Tuple{UnitRange,Vararg{UnitRange}} ) =
0 commit comments