本文整理汇总了Golang中golang.org/x/text/internal/colltab.Iter类的典型用法代码示例。如果您正苦于以下问题:Golang Iter类的具体用法?Golang Iter怎么用?Golang Iter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Iter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: anchoredForwardSearch
func (p *Pattern) anchoredForwardSearch(it *colltab.Iter) (start, end int) {
if it.Next() {
if end := p.searchOnce(it); end != -1 {
return 0, end
}
}
return -1, -1
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:8,代码来源:pattern.go
示例2: CompileString
// CompileString compiles and returns a pattern that can be used for faster
// searching.
func (m *Matcher) CompileString(s string) *Pattern {
p := &Pattern{m: m}
iter := newcolltab.Iter{Weighter: m.w}
for iter.SetInputString(s); iter.Next(); {
}
p.ce = iter.Elems
p.deleteEmptyElements()
return p
}
开发者ID:ChongFeng,项目名称:beats,代码行数:11,代码来源:search.go
示例3: Compile
// Compile compiles and returns a pattern that can be used for faster searching.
func (m *Matcher) Compile(b []byte) *Pattern {
p := &Pattern{m: m}
iter := colltab.Iter{Weighter: m.w}
for iter.SetInput(b); iter.Next(); {
}
p.ce = iter.Elems
p.deleteEmptyElements()
return p
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:10,代码来源:search.go
示例4: forwardSearch
func (p *Pattern) forwardSearch(it *colltab.Iter) (start, end int) {
for start := 0; it.Next(); it.Reset(start) {
nextStart := it.End()
if end := p.searchOnce(it); end != -1 {
return start, end
}
start = nextStart
}
return -1, -1
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:10,代码来源:pattern.go
示例5: searchOnce
// searchOnce tries to match the pattern s.p at the text position i. s.buf needs
// to be filled with collation elements of the first segment, where n is the
// number of source bytes consumed for this segment. It will return the end
// position of the match or -1.
func (p *Pattern) searchOnce(it *colltab.Iter) (end int) {
var pLevel [4]int
m := p.m
for {
k := 0
for ; k < it.N; k++ {
if v := it.Elems[k].Primary(); v > 0 {
if w, ok := p.next(&pLevel[0], colltab.Elem.Primary); !ok || v != w {
return -1
}
}
if !m.ignoreDiacritics {
if v := it.Elems[k].Secondary(); v > 0 {
if w, ok := p.next(&pLevel[1], colltab.Elem.Secondary); !ok || v != w {
return -1
}
}
} else if it.Elems[k].Primary() == 0 {
// We ignore tertiary values of collation elements of the
// secondary level.
continue
}
// TODO: distinguish between case and width. This will be easier to
// implement after we moved to the new collation implementation.
if !m.ignoreWidth && !m.ignoreCase {
if v := it.Elems[k].Tertiary(); v > 0 {
if w, ok := p.next(&pLevel[2], tertiary); !ok || int(v) != w {
return -1
}
}
}
// TODO: check quaternary weight
}
it.Discard() // Remove the current segment from the buffer.
// Check for completion.
switch {
// If any of these cases match, we are not at the end.
case pLevel[0] < len(p.ce):
case !m.ignoreDiacritics && pLevel[1] < len(p.ce):
case !(m.ignoreWidth || m.ignoreCase) && pLevel[2] < len(p.ce):
default:
// At this point, both the segment and pattern has matched fully.
// However, the segment may still be have trailing modifiers.
// This can be verified by another call to next.
end = it.End()
if it.Next() && it.Elems[0].Primary() == 0 {
if !m.ignoreDiacritics {
return -1
}
end = it.End()
}
return end
}
// Fill the buffer with the next batch of collation elements.
if !it.Next() {
return -1
}
}
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:68,代码来源:pattern.go
注:本文中的golang.org/x/text/internal/colltab.Iter类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论