lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


sorry, i will describe the problem again.

we set  t = {[8] = 1, [16] = 2, [24] = 3, [32] = 4, [14] = 5}
then t[32] = nil
then t[13] = 6

here we simply calculate hash_value = hash % size (size = 8)   

we found that
8 16 24 hash_value = 0, 13 hash_value = 5
but they are chained together
8 --> 13 --> 24 --> 16

I show it with picture so that it can better describe
https://github.com/zerocpj/lua/blob/master/lua1.png 



I tested it with other examples, this is gdb output
https://github.com/zerocpj/lua/blob/master/lua2.png  

we set a = {[101] = 1, [108] = 2, [115] = 3, [122] = 4, [129] = 5} 

101 108 115 122 mainposition is node[1], 129 mainposition is node[6], so they will be:   [0]nil    [1]101    [2]nil    [3]nil    [4]115    [5]122    [6]129    [7]108
[1]101 --> [5]122 --> [4]115 --> [7]108 --> NULL
[6]129 --> NULL

then a[122] = nil
then a[102] = 6

we found that
101 115 108 mainposition is node[1]
102 mainpositionis node[5]
but they are chained together  [1]101 --> [5]102 --> [4]115 --> [7]108 --> NULL