快速索引和QUOT;包含字符串" [英] fast index for "contains string"

查看:133
本文介绍了快速索引和QUOT;包含字符串"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I N我的应用程序已经UPTØ数以百万计的短字符串(大多少于32个字符)。我想实现一个连接列表,其中包含只有包含在搜索框中输入的整个字符串元素的搜索框。我怎样才能prebuild一个索引来查找这样的字符串快?所有排序的STL容器检查整个字符串。

I n my application i have upt o millions of short strings (mostly shorter than 32 characters). I want to implement a search box with a attached list that contains only elements that contain the whole string entered in the search box. How can i prebuild a index to find such strings fast? All sorted STL containers check the whole string.

对于输入的搜索字符串海峡我需要找到containg海峡的所有字符串:大街,司徒卢威,美国贸易代表办公室等

For a entered search string "str" i need to find all strings containg "str": "main street", "struve", "ustr" etc.

推荐答案

您可以建立一个的轮排索引的。

有关司徒卢威你会插入一个基数树(或通用搜索树):

For "struve" you would insert into a Radix tree (or a general purpose search tree):

struve$
truve$s
ruve$st
uve$str
ve$stru
e$struv
$struve

要搜索,你会从根节点搜索匹配preFIX串缀。

To search the infix you would search from the root node for matching prefix strings.

这篇关于快速索引和QUOT;包含字符串"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆