11
22"""
3- ArrayInterface. static_to_indices(A, I::Tuple) -> Tuple
3+ static_to_indices(A, I::Tuple) -> Tuple
44
55Converts the tuple of indexing arguments, `I`, into an appropriate form for indexing into `A`.
66Typically, each index should be an `Int`, `StaticInt`, a collection with values of `Int`, or a collection with values of `CartesianIndex`
@@ -29,14 +29,14 @@ This implementation differs from that of `Base.to_indices` in the following ways
2929 1.105 μs (12 allocations: 672 bytes)
3030 (1, 1, 2, 1, 1, 2, 1, 1, 2, 1)
3131
32- julia> @btime ArrayInterface. static_to_indices(\$ x, \$ inds2)
32+ julia> @btime static_to_indices(\$ x, \$ inds2)
3333 0.041 ns (0 allocations: 0 bytes)
3434 (1, 1, 2, 1, 1, 2, 1, 1, 2, 1)
3535
3636 julia> @btime Base.to_indices(\$ x, \$ inds3);
3737 340.629 ns (14 allocations: 768 bytes)
3838
39- julia> @btime ArrayInterface. static_to_indices(\$ x, \$ inds3);
39+ julia> @btime static_to_indices(\$ x, \$ inds3);
4040 11.614 ns (0 allocations: 0 bytes)
4141
4242 ```
8080end
8181
8282"""
83- ArrayInterface. to_index([::IndexStyle, ]axis, arg) -> index
83+ to_index([::IndexStyle, ]axis, arg) -> index
8484
85- Convert the argument `arg` that was originally passed to `ArrayInterface. static_getindex` for the
85+ Convert the argument `arg` that was originally passed to `static_getindex` for the
8686dimension corresponding to `axis` into a form for native indexing (`Int`, Vector{Int}, etc.).
8787
88- `ArrayInterface. to_index` supports passing a function as an index. This function-index is
88+ `to_index` supports passing a function as an index. This function-index is
8989transformed into a proper index.
9090
9191```julia
9292julia> using ArrayInterface, Static
9393
94- julia> ArrayInterface. to_index(static(1):static(10), 5)
94+ julia> to_index(static(1):static(10), 5)
95955
9696
97- julia> ArrayInterface. to_index(static(1):static(10), <(5))
97+ julia> to_index(static(1):static(10), <(5))
9898static(1):4
9999
100- julia> ArrayInterface. to_index(static(1):static(10), <=(5))
100+ julia> to_index(static(1):static(10), <=(5))
101101static(1):5
102102
103- julia> ArrayInterface. to_index(static(1):static(10), >(5))
103+ julia> to_index(static(1):static(10), >(5))
1041046:static(10)
105105
106- julia> ArrayInterface. to_index(static(1):static(10), >=(5))
106+ julia> to_index(static(1):static(10), >=(5))
1071075:static(10)
108108
109109```
110110
111111Use of a function-index helps ensure that indices are inbounds
112112
113113```julia
114- julia> ArrayInterface. to_index(static(1):static(10), <(12))
114+ julia> to_index(static(1):static(10), <(12))
115115static(1):10
116116
117- julia> ArrayInterface. to_index(static(1):static(10), >(-1))
117+ julia> to_index(static(1):static(10), >(-1))
1181181:static(10)
119119```
120120
@@ -259,10 +259,10 @@ end
259259to_axis (S:: IndexLinear , axis, inds) = StaticInt (1 ): static_length (inds)
260260
261261"""
262- ArrayInterface. static_getindex(A, args...)
262+ static_getindex(A, args...)
263263
264264Retrieve the value(s) stored at the given key or index within a collection. Creating
265- another instance of `ArrayInterface. static_getindex` should only be done by overloading `A`.
265+ another instance of `static_getindex` should only be done by overloading `A`.
266266Changing indexing based on a given argument from `args` should be done through,
267267[`to_index`](@ref), or [`to_axis`](@ref).
268268"""
@@ -380,7 +380,7 @@ _known_first_isone(ind) = known_first(ind) !== nothing && isone(known_first(ind)
380380end
381381
382382"""
383- ArrayInterface. setindex!(A, args...)
383+ setindex!(A, args...)
384384
385385Store the given values at the given key or index within a collection.
386386"""
@@ -446,10 +446,10 @@ If `first` of an instance of type `T` is known at compile time, return it.
446446Otherwise, return `nothing`.
447447
448448```julia
449- julia> ArrayInterface. known_first(typeof(1:4))
449+ julia> known_first(typeof(1:4))
450450nothing
451451
452- julia> ArrayInterface. known_first(typeof(Base.OneTo(4)))
452+ julia> known_first(typeof(Base.OneTo(4)))
4534531
454454```
455455"""
@@ -469,10 +469,10 @@ If `last` of an instance of type `T` is known at compile time, return it.
469469Otherwise, return `nothing`.
470470
471471```julia
472- julia> ArrayInterface. known_last(typeof(1:4))
472+ julia> known_last(typeof(1:4))
473473nothing
474474
475- julia> ArrayInterface. known_first(typeof(static(1):static(4)))
475+ julia> known_first(typeof(static(1):static(4)))
4764764
477477
478478```
@@ -490,10 +490,10 @@ If `step` of an instance of type `T` is known at compile time, return it.
490490Otherwise, return `nothing`.
491491
492492```julia
493- julia> StaticArrayInterface. known_step(typeof(1:2:8))
493+ julia> known_step(typeof(1:2:8))
494494nothing
495495
496- julia> StaticArrayInterface. known_step(typeof(1:4))
496+ julia> known_step(typeof(1:4))
4974971
498498
499499```
0 commit comments