Prefix search through list/dictionary using .NET StringDictionary?

前端 未结 5 1206
情歌与酒
情歌与酒 2021-01-15 09:06

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, b

5条回答
  •  半阙折子戏
    2021-01-15 09:42

    StringDictionary is merely a hash table where the keys and values are strings. This existed before generics (when Dictionary was not possible).

    The data structure that you want here is a trie. There are implementations on CodeProject:

    1. Phone Directory Implementation Using TRIE
    2. A Reusable Prefix Tree using Generics in C# 2.0

    Or, if you're that kind of guy, roll your own (see CLRS).

提交回复
热议问题