In the application, I will have from 3,000 to 30,000 lines. After creation (reading from files is unordered) there will not be many lines that will be added often (but sometimes it will be!). Deleting rows will also happen infrequently. Comparison of the line with the saved ones will occur frequently.
Which structure can I use best: a hash table, a tree (Red-Black, Splay, ....) or just an ordered list (maybe StringArray?)?
(Additional note: a reference to a good C # implementation will also be appreciated)
, -. , HashSet<T> . (, , Dictionary<T> , , .)
HashSet<T>
Dictionary<T>
HashSet<T> n. , .
n
O(1)
O(n)
- , - , . - , /- .
HashSet . , O (1).
- , . , , O (n).
HashSet VB 6 ( ) .NET 3.5, , , . , API, .
HashSet, , , . ( ), HashSet . - , . , HashSet .
, . , , .
, , ( , ). - , ( #), , , . , , , , ( , , ).
, HashSet<T>, , " ". IEqualityComparer<string> (, StringComparer) ..
IEqualityComparer<string>
StringComparer
, , , " , ?" , , , . (List<T> BinarySearch, , SortedList SortedDictionary , . , SortedDictionary , , , , , .)
List<T>
SortedList
SortedDictionary
, " ", HashSet<T> - . , :)
" , " ( ), trie. "" , "" , . - .
N = 30 000 , . , k * N Optional k ( , , . " ", , O (n), , O (n) , " " . , /.
Source: https://habr.com/ru/post/1710915/More articles:How to set the value of the result? - coding-styleLinq to XML Noob question - excellent and sorted by attributes - linqQuestion about the wireframe of objects - ormpossible errors in 'including * .c files' style C programming - cParallel Algorithms and Data Structures - algorithmHow can I build a grammar that generates this language? - context-free-grammarHow to use classes? - classmsginit command line argument email addresses? - linuxWhat is the use of chords? - c #ALT-TAB Pixelated Application Icon - winformsAll Articles