Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2020-08

How reliable are Hashlists in Contnrs

4 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

I've noticed some problem with another hashlist that after adding about 2000 items to it, it starts to have problems. There are duplicates added (possibly a collision?)

Is there a such thing as a perfect hashlist which never has a collision, or will they always have problems... In that case a regular but slower List might be of use for perfection.

If there is an error would it throw an exception?

Sven Barth
to Unknown author: I've noticed some problem with another hashlist that after adding about 2000 items to it,…
Lars wrote 9 lines
I've noticed some problem with another hashlist that after adding about 2000 items to it, it starts to have problems. There are duplicates added (possibly a collision?) Is there a such thing as a perfect hashlist which never has a collision, or will they always have problems... In that case a regular but slower List might be of use for perfection. If there is an error would it throw an exception?

Hash lists will always create collisions if enough elements are added. After all their purpose is to speed up the search thus they reduce the search space. This is by design.

If there should really be a problem with adding an element then an exception will be thrown.

Regards,
Sven

Unknown author
to Unknown author: I've noticed some problem with another hashlist that after adding about 2000 items to it,…
I've noticed some problem with another hashlist that after adding about 2000 items to it, it starts to have problems.

BTW, sorry to be more clear I meant I used another hashlist unit, not the contnrs one but another open source public domain one

This one:

https://github.com/z505/delphi-hashlist

And had problems with it.

I will try out contnrs one to compare soon!