Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrest hash counting of HashTable #49

Open
awen-li opened this issue Sep 16, 2021 · 0 comments
Open

Incorrest hash counting of HashTable #49

awen-li opened this issue Sep 16, 2021 · 0 comments

Comments

@awen-li
Copy link

awen-li commented Sep 16, 2021

Description

During using the lib HashTable, the counting is unexpected when the item number is larger than the table size.

Steps/Code/Corpus to Reproduce

from bounter import HashTable

Ht = HashTable(buckets=4)

Loop = 8
ItemNum=8
print ("Loop = ", Loop)

for i in range (0, Loop):
    for s in range (0, ItemNum):
        Ht.increment(str (s))

for s in range (0, 8):
    print ("Ht[%d] = %d" %(s, Ht[str (s)]))

Expected Results

Ht[0] = 8
Ht[1] = 8
Ht[2] = 8
Ht[3] = 8
Ht[4] = 0
Ht[5] = 0
Ht[6] = 0
Ht[7] = 0

Actual Results

Ht[0] = 0
Ht[1] = 0
Ht[2] = 0
Ht[3] = 0
Ht[4] = 0
Ht[5] = 0
Ht[6] = 0
Ht[7] = 1

Versions

the main branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant