1

Topic: The help in implementation a function hash is necessary.

All greetings, Would be desirable to implement a hash function (what to palm off in std:: unordered_map) for lines, here on such here to a rule: There is a line "abc" == "bca" == "acb", . lines are equal, if at all of them letters coincide, the order is not important. It is ideal, if collisions are not, or they will be shown to a minimum. Ideas?

2

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> All greetings, E> Would be desirable to implement a hash function (what to palm off in std:: map) for lines, here on such here to a rule: E> There is a line "abc" == "bca" == "acb", . lines are equal, if at all of them letters coincide, the order is not important. E> it is ideal, if collisions are not, or they will be shown to a minimum. E> ideas? Races the order is not important to lead that to their one order, and then to hash.

3

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> All greetings, E> Would be desirable to implement a hash function (what to palm off in std:: map) for lines, here on such here to a rule: E> There is a line "abc" == "bca" == "acb", . lines are equal, if at all of them letters coincide, the order is not important. E> it is ideal, if collisions are not, or they will be shown to a minimum. E> ideas? To sort letters in line, then to calculate

4

Re: The help in implementation a function hash is necessary.

Hello, Qulac, you wrote: Q> Hello, Engler, you wrote: E>> All greetings, E>> Would be desirable to implement a hash function (what to palm off in std:: map) for lines, here on such here to a rule: E>> There is a line "abc" == "bca" == "acb", . lines are equal, if at all of them letters coincide, the order is not important. E>> it is ideal, if collisions are not, or they will be shown to a minimum. E>> ideas? Q> races the order is not important to lead that to their one order, and then to hash. Well if to sort, as  so: Bogosort . hash coding function will sort values? Does not approach.

5

Re: The help in implementation a function hash is necessary.

Hello, the Corkcrew, you wrote: Hello, Engler, you wrote: E>> All greetings, E>> Would be desirable to implement a hash function (what to palm off in std:: map) for lines, here on such here to a rule: E>> There is a line "abc" == "bca" == "acb", . lines are equal, if at all of them letters coincide, the order is not important. E>> it is ideal, if collisions are not, or they will be shown to a minimum. E>> ideas? To sort letters in line, then to calculate  Answered Qulac. It would be desirable it to avoid.

6

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> All greetings, E> Would be desirable to implement a hash function (what to palm off in std:: map) for lines, here on such here to a rule: E> There is a line "abc" == "bca" == "acb", . lines are equal, if at all of them letters coincide, the order is not important. E> it is ideal, if collisions are not, or they will be shown to a minimum. Add the codes of all letters. Either . Or .

7

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> Hello, the Corkcrew, you wrote:>> Hello, Engler, you wrote: E>>> All greetings, E>>> Would be desirable to implement a hash function (what to palm off in std:: map) for lines, here on such here to a rule: E>>> There is a line "abc" == "bca" == "acb", . lines are equal, if at all of them letters coincide, the order is not important. E>>> it is ideal, if collisions are not, or they will be shown to a minimum. E>>> ideas?> to Sort letters in line, then to calculate  E> Answered Qulac. E> it would be desirable it to avoid. vmpire answered.

8

Re: The help in implementation a function hash is necessary.

Hello, vmpire, you wrote: V> Add the codes of all letters. Either . Or . Thought of it, but it is a lot of collisions out of the blue: a ^ a = 0 b ^ b = 0 Total and multiplication the same history: a + z == b + y/

9

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote:> to Sort letters in line, then to calculate  E> Answered Qulac. E> it would be desirable it to avoid. Well then simply to count an amount of entrances of each letter. From result (dict) to calculate .

10

Re: The help in implementation a function hash is necessary.

Hello, the Corkcrew, you wrote: Hello, Engler, you wrote:>> to Sort letters in line, then to calculate  E>> Answered Qulac. E>> it would be desirable it to avoid. Well then simply to count an amount of entrances of all letters. From result to calculate . Counted for a line abc: a=1, b=1, c=1. How to calculate a hash? After your udpate, the question did not change)

11

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: V>> Add the codes of all letters. Either . Or . E> Thought of it, but it is a lot of collisions out of the blue: E> a ^ a = 0 E> b ^ b = 0 E> the Total and multiplication the same history: a + z == b + y/Well combine, ,  and multiplication. The probability sharply decreases. I wrote idea, instead of ready implementation. In general, use any ( not one) the associative function of the codes of characters.

12

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> Hello, the Corkcrew, you wrote:>> Hello, Engler, you wrote:>>>> to Sort letters in line, then to calculate  E>>> Answered Qulac. E>>> it would be desirable it to avoid.>> Well then simply to count an amount of entrances of all letters. From result to calculate . E> Counted for a line abc: a=1, b=1, c=1. How to calculate a hash? E> after your udpate, the question did not change) If to paraphrase that that I wrote to lead to their one order that it too most earlier what to lead to one type. Though to a line of a type "a=1, b=1, c=1" though to a dial-up of counters, and a hash we calculate a standard function a standard method.

13

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> Hello, vmpire, you wrote: V>> Add the codes of all letters. Either . Or . E> Thought of it, but it is a lot of collisions out of the blue: There is a cheap method gets rid of simple collisions. It is necessary to do on the contrary: not to add the codes of characters, and then to take from the total a hash, and at first to take a hash irrespective of each character, and then already to add hashes smile Well that is, if at you characters, let us assume, 256 hash coding can be arranged so: constexpr uint64_t static_random_data [256] {0x7b84175e77e850efull, 0x5f84021c493dace1ull, 0xcfe619fd16bcdb0full, 0xe3a9493fc706d8eeull...}; uint64_t hash (string_view str) {uint64_t t = 0; for (unsigned char c: str) {t + = static_random_data [c];} return t;} And generally, a hash of function which do not depend on the order of arguments, are called "symmetric hash functions" - it is possible to search on these keywords.

14

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> Counted for a line abc: a=1, b=1, c=1. How to calculate a hash? For example, so: hash (a, 1) ^ hash (b, 1) ^ hash (c, 1)

15

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> Hello, vmpire, you wrote: V>> Add the codes of all letters. Either . Or . E> Thought of it, but it is a lot of collisions out of the blue: E> a ^ a = 0 E> b ^ b = 0 E> the Total and multiplication the same history: a + z == b + y/Well something like: int hash (const char *s) {int c, h = 0; while ((c = (int) (unsigned char) * (s ++))! = 0) {h = (h * A + c * B) C %;} return h;} A, B and the C - is enough great numbers, odd and mutually simple among themselves.

16

Re: The help in implementation a function hash is necessary.

Hello, Engler, you wrote: E> It would be desirable to implement a hash function (what to palm off in std:: map) And std:: map on a hash functions unless works?

17

Re: The help in implementation a function hash is necessary.

W> And generally, a hash of function which do not depend on the order of arguments, are called "symmetric hash functions" - it is possible to search on these keywords. Thanks, very interesting.

18

Re: The help in implementation a function hash is necessary.

Hello, Maxim Rogozhin, you wrote: > Hello, Engler, you wrote: E>> It would be desirable to implement a hash function (what to palm off in std:: map) > And std:: map on a hash functions unless works? Thanks, it was sealed up: unordered_map.