I am considering a data structure for storing a large array of strings in memory. Rows will be inserted at the beginning of the program and will not be added or deleted while the program is running. The most important point is that the search procedure should be as fast as possible. Saving memory does not matter. I am inclined towards the standard hash_set structure from the standard library, which allows me to search for elements in the structure with approximately constant time. But this did not guarantee that this time would be short. Anyone suggest a better standard solution?
Many thanks!
A Trie , . -
, , , perfect hash -.
, - , , , . , , , , . , , . , , - ( Trie, -, Judy splay, ), . , .
, .
, , google-sparsehash. / (re), , -/ . . performance. , -. ( : murmur2.)
.
- / "", , Directed Acyclic Word Graph Compact Directed Acyclic Word Graph, * , -, .
** : , , , .. - , (, , ..). *
- , , , .
, , , , , , Raymond Chen .
- - try, . trie , - , . , . , .
, , : , , , , , , ( ) . , ( , ).
:
This supports cache locality, allows you to efficiently search (it will search ~ 4 billion lines with 32 comparisons in space), and it is very simple to implement. There is no need to get fantasies from attempts, because they are complex and slower than they appear (especially if you have long lines).
Accidental side effect: in combination with http://blogs.msdn.com/b/oldnewthing/archive/2005/05/19/420038.aspx you will stop!
Source: https://habr.com/ru/post/1762186/More articles:How to debug Javascript registered with RegisterClientScriptBlock method - javascriptJava unlimited thread stops after a while - javaСписок - Правильная коллекция для использования для большого количества предметов? - c#Technology for a robust, persistent stack - c #How to check if there are write permissions in the current path - phpКлиент WCF для службы WSE 3.0 - wcfHow to call javascript callback from java applets thread? - javaWPF / XAML associates element width with a fraction of screen size - c #CSS Sprites: problem with form input (text field) - cssNew theme for class instance (C #) - multithreadingAll Articles