用法一
findnext(A, i)在 A 的 true 元素的 i 之后或包括 i 之后查找下一个索引,如果未找到,则查找 nothing。
索引与   和 keys(A)   返回的索引类型相同。pairs(A) 
例子
julia> A = [false, false, true, false]
4-element Vector{Bool}:
 0
 0
 1
 0
julia> findnext(A, 1)
3
julia> findnext(A, 4) # returns nothing, but not printed in the REPL
julia> A = [false false; true false]
2×2 Matrix{Bool}:
 0  0
 1  0
julia> findnext(A, CartesianIndex(1, 1))
CartesianIndex(2, 1)用法二
findnext(predicate::Function, A, i)查找 A 的元素的 i 之后或包含 A 的下一个索引,其中 predicate 返回 true 或 nothing 如果未找到。
索引与   和 keys(A)   返回的索引类型相同。pairs(A) 
例子
julia> A = [1, 4, 2, 2];
julia> findnext(isodd, A, 1)
1
julia> findnext(isodd, A, 2) # returns nothing, but not printed in the REPL
julia> A = [1 4; 2 2];
julia> findnext(isodd, A, CartesianIndex(1, 1))
CartesianIndex(1, 1)用法三
findnext(pattern::AbstractString, string::AbstractString, start::Integer)
findnext(pattern::AbstractPattern, string::String, start::Integer)从位置 start 开始,在 string 中查找下一个出现的 pattern。 pattern 可以是字符串或正则表达式,在这种情况下 string 必须是 String 类型。
返回值是找到匹配序列的索引范围,例如 s[findnext(x, s, i)] == x :
findnext("substring", string, i) == start:stop 使得 string[start:stop] == "substring" 和 i <= start 或 nothing 如果不匹配。
例子
julia> findnext("z", "Hello to the world", 1) === nothing
true
julia> findnext("o", "Hello to the world", 6)
8:8
julia> findnext("Lang", "JuliaLang", 2)
6:9用法四
findnext(ch::AbstractChar, string::AbstractString, start::Integer)从位置 start 开始,在 string 中查找下一个出现的字符 ch。
Julia 1.3
此方法至少需要 Julia 1.3。
例子
julia> findnext('z', "Hello to the world", 1) === nothing
true
julia> findnext('o', "Hello to the world", 6)
8相关用法
- Julia findnext()用法及代码示例
- Julia findfirst方法用法及代码示例
- Julia findall方法用法及代码示例
- Julia findmax()用法及代码示例
- Julia findlast方法用法及代码示例
- Julia findprev方法用法及代码示例
- Julia findmin()用法及代码示例
- Julia findfirst()用法及代码示例
- Julia findmax用法及代码示例
- Julia findprev()用法及代码示例
- Julia findlast()用法及代码示例
- Julia findmin用法及代码示例
- Julia finalizer用法及代码示例
- Julia fill!用法及代码示例
- Julia first方法用法及代码示例
- Julia firstindex用法及代码示例
- Julia fieldnames用法及代码示例
- Julia filter!用法及代码示例
- Julia fill用法及代码示例
- Julia fieldname用法及代码示例
- Julia fieldtypes用法及代码示例
- Julia first用法及代码示例
- Julia filter用法及代码示例
- Julia first()用法及代码示例
- Julia float方法用法及代码示例
注:本文由纯净天空筛选整理自julialang.org 大神的英文原创作品 Base.findnext — Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
