Skip to content

Commit f580266

Browse files
committed
add
1 parent db6bb65 commit f580266

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

go.mod

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@ module github.com/googege/gotools
22

33
go 1.14
44

5-
require github.com/google/uuid v1.1.1
5+
require (
6+
github.com/googege/godata v0.7.0
7+
github.com/google/uuid v1.1.1
8+
)

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1+
github.com/googege/godata v0.7.0 h1:kHoJ4a2sVIRisdTKxneCTrP8JpwcTTjjhFU/juMxH24=
2+
github.com/googege/godata v0.7.0/go.mod h1:A/5/f6RN0WjJFrMGDnNcFolIQ2eiRgIlXSWWAU5UddQ=
13
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
24
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
5+
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
6+
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=

str/str.go

+10
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
11
package str
2+
3+
type Str interface {
4+
IsExit(v interface{})bool
5+
Insert(v interface{})
6+
}
7+
8+
9+
func StrIs(s Str,value interface{})bool{
10+
return s.IsExit(value)
11+
}

str/trie.go

+19
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
package str
2+
3+
import "github.com/googege/godata"
4+
5+
type Trie struct {
6+
Value *godata.Trie
7+
}
8+
9+
func (t *Trie) IsExit(v interface{}) bool {
10+
vt := v.(string)
11+
b, _ := t.Value.StartsWith(vt)
12+
return b
13+
}
14+
func (t *Trie) Insert(v interface{}) {
15+
t.Value.Insert(v.(string))
16+
}
17+
// return a new Trie.
18+
func NewTrie() Str {
19+
return &Trie{Value: godata.NewTrie()}
20+
}

0 commit comments

Comments
 (0)