Exemplo n.º 1
0
func (s *Suggestion) buildOrigSuggestionMap(items []Item) {
	s.origSuggestionMap = treemap.New()

	for _, item := range items {
		s.origSuggestionMap.Replace(treemap.StrKey(item.Keyword), item)
	}
	return
}
Exemplo n.º 2
0
func (s *Suggestion) buildAbbrSuggestionMap(items []Item) {
	s.abbrSuggestionMap = treemap.New()

	for _, item := range items {
		abbrStr := s.pinyin.WordStr2abbrString(item.Keyword)
		s.abbrSuggestionMap.Replace(treemap.StrKey(abbrStr), item)
	}
	return
}
Exemplo n.º 3
0
func (s *Suggestion) buildPinyinSuggestionMap(items []Item) {
	s.pinyinSuggestionMap = treemap.New()

	for _, item := range items {
		pinyinStr := s.pinyin.WordStr2pinyinStr(item.Keyword)
		s.pinyinSuggestionMap.Replace(treemap.StrKey(pinyinStr), item)
	}
	return
}
Exemplo n.º 4
0
func testRbtree() {
	t := time.Now()
	nanosec := t.Nanosecond()
	seed := int64(nanosec)
	rand.Seed(seed)
	key := rand.Int()
	log.Println("kkk: ", key)

	tree := treemap.New()

	tree.Add(treemap.IntKey(key), "haha")
	tree.Add(treemap.IntKey(rand.Int()), "hello")

	log.Println(tree.Find(treemap.IntKey(key)).Value)

}