trie

package
v0.0.0-...-012d1c6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DoubleArrayTrie

type DoubleArrayTrie struct {
	// contains filtered or unexported fields
}

DoubleArrayTrie trie

func NewDATrie

func NewDATrie() *DoubleArrayTrie

NewDATrie return DoubleArrayTrie

func (*DoubleArrayTrie) Build

func (dat *DoubleArrayTrie) Build(words []string) error

Build 构建一个DATrie 要求:

1:必须utf8编码
2:必须不能重复,且递增有序,即必须保证相同前缀的短的在前边,否则会导致访问越界

func (*DoubleArrayTrie) Match

func (dat *DoubleArrayTrie) Match(str string, longest bool) int

Match 匹配单词,longest 为true匹配最长的一个单词,false匹配第一个 返回值,0没有匹配到,>0匹配到的长度

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL