AutoComplete from 10,000 items in .NET.

I have a collection from memory of about 10 thousand objects. I want to give users the ability to type part of the name or description of an item and display an autocomplete list. What is an effective way to do this? I really need the fastest response time, users are very fast.

Thank you very much mary

+3
source share
7 answers

This is not a specific .net answer, but the usual approach to this problem is to create an index and pre-compute autocomplete lists that are stored in the hierarchical map map card ...- of-maps-of-lists (see below). This is basically an implementation of trie .

, - (REAL hash map, O (1)), . "XYZ" , , "XYZ"; "XYZA", "XYZB",... .. , N (N ), , N- .

M N ( , , >= M , ) .

:

TopMap => {
          'A' => Map_for_A
          'B' => Map_for_B
              ...
          }

Map_For_A => {
          'AA' => Map_for_AA
          'AB' => Map_for_AB
              ...
          }
Map_For_AB => {
          'ABC' => Map_for_ABC
          'ABD' => Map_for_ABD
              ...
          }
Map_For_ABD => {
          'ABDE' => List_For_ABDE
          'ABDX' => List_For_ABDX
          }
+1
+9

10 000 .

.

foreach(cItem Item in ItemList)
{
     if(regex.match(Item.Name, "expression"))
         //Add Item to autocomplete results;


         //Break if more than 10 matches

}



for(i = 0; i < 10 && i < autocomplete_results.Length; ++i)
{
          // display first 10 matches
}
+1

Trie ( ) . . , .

node Trie , N- , N - node. .

, node, . , .

, , . , .

+1
0

, , - , "E" E , , . , 3 ( ) ?

, () 3- 4- , :

Dictionary<String, List<Item>> itemsByKey;
0

, . - ASP.NET, AjaxControlToolkit.

Here you can find a demo: http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/AutoComplete/AutoComplete.aspx

0
source

Source: https://habr.com/ru/post/1787222/


All Articles