I use Dictionary<>bazillion to store items. Is it possible to assume that as long as the server memory has enough space to accommodate these bazillion elements, I will get about O (1) extraction of elements from it? What should I know about using a shared dictionary as a huge cache when performance is important?
Dictionary<>
EDIT: Shouldn't I rely on default implementations? What does a good hashing function do?
It all depends on how good the hashing functionality that your "bazillion items" supports - if their hashing function is not excellent (so many conflicts lead to results), your performance will deteriorate as the dictionary grows.
You must measure it and find out. This is someone who knows the exact use of your vocabulary, so you can measure it to make sure it matches your needs.
: , , . , , , . , .., . , ; , , , .
; , bazillion-item, , , , , .
, O (1). g O (1). , , , GetHashCode , , Equals.
, : , , "" -.
Yes, you will have about O (1) no matter how many objects you put in the dictionary. But for the dictionary to be fast, your key objects must provide a sufficient implementation of GetHashCode, because the dictionary uses a hash table inside itself.
Source: https://habr.com/ru/post/1720979/More articles:Insert node into xml using php - xmlДоступ к перегрузке и назначение С++ - c++Сериализация списка анонимных делегатов - c#How to disable RequireHttps MVC.NET version 2 attribute? - asp.net-mvcUsing grep and ls in an FTP client? - grepPHP class arguments in functions - functionHow do you structure your jQuery code? - javascriptальтернатива междоменному javascripting? - javascriptHow to check if a process with pid X is a zombie? - cMathematica Graphical Programming Schedule - image-processingAll Articles