示例#1
0
文件: inflate.go 项目: koron/gomigemo
func recursive_each(n trie.Node, proc func(trie.Node)) {
	n.Each(func(m trie.Node) bool {
		proc(m)
		recursive_each(m, proc)
		return true
	})
}
示例#2
0
文件: pattern.go 项目: koron/gomigemo
// splitLabels split children which have children or not.
func (m *matcher) splitLabels(n trie.Node) (label string, nodes *list.List) {
	l := list.New()
	b := new(bytes.Buffer)
	n.Each(func(t trie.Node) bool {
		if t.HasChildren() {
			l.PushBack(t)
		} else {
			b.WriteRune(t.Label())
		}
		return true
	})
	return b.String(), l
}