使用.NET StringDictionary在列表/字典中进行前缀搜索? [英] Prefix search through list/dictionary using .NET StringDictionary?
问题描述
我想知道.NET是否提供任何标准功能来通过列表或字典对象进行前缀搜索.我遇到了 StringDictionary
,但不知道是否可以为我做这件事.
I was wondering if .NET offers any standard functionality for doing a prefix search through a list or a dictionary object. I came across the StringDictionary
, but couldn't figure out if it can do that for me.
如果它可以进行前缀搜索,还可以进行子字符串搜索还是让我使用正则表达式之类的东西进行搜索?
And if it can do a prefix search, can it also do substring search or let me search using something like a regular expression?
谢谢.
推荐答案
StringDictionary
只是一个哈希表,其中的键和值是 string
.这在通用名称之前就存在(当不可能使用 Dictionary< string,string>
时).
StringDictionary
is merely a hash table where the keys and values are string
s. This existed before generics (when Dictionary<string, string>
was not possible).
您在此处需要的数据结构是 trie .在 CodeProject 上有实现:
The data structure that you want here is a trie. There are implementations on CodeProject:
或者,如果您是那种人,请自己动手(请参阅 CLRS ).
Or, if you're that kind of guy, roll your own (see CLRS).
这篇关于使用.NET StringDictionary在列表/字典中进行前缀搜索?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!