So this is a good picture in the hash maps of the Wikipedia article:
Everything is still available, except for the hash function in the middle.
1
John Smith
2
Lisa Smith
This is one of the key issues with hashmaps / dictionaries, etc. You should choose a good hash function. A very bad but fast hash function may be the length of the keys. You immediately see that you will get many collisions (different keys, but the same hash). Another bad hash function might be the ASCII value of the first character of your key. Lots of collisions too.Therefore, you need a function that is much better than these two. You can add (xor) all ASCII values of key characters and mix length, for example. In practice, you often depend on the values (fields) of the object that you want to use for the hash (the same values give the same value type hash =>). For reference types, you can, for example, navigate in a memory location.
. - .
,
- :
$hash = $string[0] % HASH_TABLE_SIZE;
0 HASH_TABLE_SIZE - 1, . -.
- , , .
- ( ) ( -). . , - , . -, - - .
, . (J, o, h, n...), ( ). ASCII UTF , . , , (). , , modulo .
, , , "ab" "ba" . - , - , - .
, - ( / ) MSDN:
2: , Hashtable
, .NET( , .NET ), .
, -, , . -, "1", .
Source: https://habr.com/ru/post/1741082/More articles:CSS How to prevent the browser from showing scrollbars when the div goes outside the window? - htmlStatic analysis structure for eclipse? - code-analysisIs there a way to change the name of OpenFileDialog in Silverlight 3? - silverlightcllocation and mkreversegeocoder - iphonejQueryUI Modal confirmation dialog when submitting a form - jqueryИспользование не примитивных типов в ServiceOperation для службы данных WCF (3.5SP1) - designAdd an icon to your home screen, such as Safari - iosHow to catch all unhandled exceptions in a .net assembly (library type, not application) - .netImplementation of "Add to Home Screen", ala Safari - safariBest way to get a single value from a DataTable? - c #All Articles