@@ -323,18 +323,26 @@ end
323
323
324
324
"""
325
325
eachindex(A...)
326
+ eachindex(::IndexStyle, A::AbstractArray...)
326
327
327
328
Create an iterable object for visiting each index of an `AbstractArray` `A` in an efficient
328
329
manner. For array types that have opted into fast linear indexing (like `Array`), this is
329
- simply the range `1:length(A)`. For other array types, return a specialized Cartesian
330
- range to efficiently index into the array with indices specified for every dimension. For
331
- other iterables, including strings and dictionaries, return an iterator object
332
- supporting arbitrary index types (e.g. unevenly spaced or non-integer indices).
330
+ simply the range `1:length(A)` if they use 1-based indexing.
331
+ For array types that have not opted into fast linear indexing, a specialized Cartesian
332
+ range is typically returned to efficiently index into the array with indices specified
333
+ for every dimension.
334
+
335
+ In general `eachindex` accepts arbitrary iterables, including strings and dictionaries, and returns
336
+ an iterator object supporting arbitrary index types (e.g. unevenly spaced or non-integer indices).
337
+
338
+ If `A` is `AbstractArray` it is possible to explicitly specify the style of the indices that
339
+ should be returned by `eachindex` by passing a value having `IndexStyle` type as its first argument
340
+ (typically `IndexLinear()` if linear indices are required or `IndexCartesian()` if Cartesian
341
+ range is wanted).
333
342
334
343
If you supply more than one `AbstractArray` argument, `eachindex` will create an
335
- iterable object that is fast for all arguments (a [`UnitRange`](@ref)
336
- if all inputs have fast linear indexing, a [`CartesianIndices`](@ref)
337
- otherwise).
344
+ iterable object that is fast for all arguments (typically a [`UnitRange`](@ref)
345
+ if all inputs have fast linear indexing, a [`CartesianIndices`](@ref) otherwise).
338
346
If the arrays have different sizes and/or dimensionalities, a `DimensionMismatch` exception
339
347
will be thrown.
340
348
0 commit comments