Hash table weird storage issues - 08/12/04 08:51 AM
Hi,
I'm not sure if I should put this here or the bug section, but I'll put it here anyway.
I'm basically filtering snotices and such and going '/hadd -m inc_var nickname text here'. inc_var starts out as 1 but increases each time before the /hadd is called. The reason for this is I want to recall the hash list in the order of each thing happening, but when I make a simple script to list each element in the hash table, I find that it is stored in a weird order.
For example, /viewhash name shouls look like this ->
1 nickname hi there
2 nickname how are you
3 nickname not too bad
but I'm getting
3 nickname not too bad
1 nickname hi there
2 nickname how are you
Those are just made up values, but you get the idea. Do hash tables store in according to the size of the data or is this just odd? I'm using mIRC 6.16 if that helps. This is a quick re-write of the script ...
Any help to clear this up would be great.
Thanks in advance,
Daniel
I'm not sure if I should put this here or the bug section, but I'll put it here anyway.
I'm basically filtering snotices and such and going '/hadd -m inc_var nickname text here'. inc_var starts out as 1 but increases each time before the /hadd is called. The reason for this is I want to recall the hash list in the order of each thing happening, but when I make a simple script to list each element in the hash table, I find that it is stored in a weird order.
For example, /viewhash name shouls look like this ->
1 nickname hi there
2 nickname how are you
3 nickname not too bad
but I'm getting
3 nickname not too bad
1 nickname hi there
2 nickname how are you
Those are just made up values, but you get the idea. Do hash tables store in according to the size of the data or is this just odd? I'm using mIRC 6.16 if that helps. This is a quick re-write of the script ...
Code:
alias viewhash { var %i 1 echo -at Listing hashtable entries for $$1 ;to get the right order while($hget($$1, %i) { echo -at [H] $hget($$1, %i).item $hget(%i) $hget($$1, %i).data inc %i } echo -at End Of List } on *:SNOTICE:*: { if ($2 == GLOBAL) { var %nick = $left($6, -1) ;just for those that like $eval ;) ;from memory, you can just use /inc, but I like to be safe if (%total_ [ $+ [ %nick ] ]) { inc %total_ [ $+ [ %nick } ] } else { %total_ [ $+ [ %nick ] ] = 1 } hadd -m %nick %total_ [ $+ [ %nick ] ] $6- } }
Any help to clear this up would be great.
Thanks in advance,
Daniel