mIRC Home    About    Download    Register    News    Help

Print Thread
S
saragani
saragani
S
If I create a hash table:

/hmake saragani 10

and then add the lines:

/hadd saragani aa 1
/hadd saragani bb 1
/hadd saragani cc 1
/hadd saragani dd 1
/hadd saragani ee 1

Then when writting the following, I will get:

//echo -a $hget(saragani,1).item
cc

//echo -a $hget(saragani,2).item
bb


//echo -a $hget(saragani,3).item
dd


//echo -a $hget(saragani,4).item
aa


//echo -a $hget(saragani,5).item
ee



And it doesn't make sense. It is not being ordered by the order that I added them, and it is not being ordered alphabeticly, and it is not being ordered by the value.

How it is ordered, and can I make it being ordered by the order I added them???
confused

Last edited by saragani; 15/07/03 04:37 PM.
Joined: Dec 2002
Posts: 2,958
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Dec 2002
Posts: 2,958
There isn't meant to be an order.

C
codemastr
codemastr
C
Hash tables are not logically ordered. They aren't meant to access data sequentially, hash tables are meant for super fast lookups. Therefore the hash table is ordered so that finding an item in a hash of ~10000 items takes at most ~3 checks. If you want ordered data, then download an array script of which there are many.

S
saragani
saragani
S
Ok, thanks.

I changed my script so it will work with non ordered hash tables.


Link Copied to Clipboard