Raised This Month: $ Target: $400
 0% 

Array module and iterating through a map


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
akysiev
Junior Member
Join Date: Mar 2006
Location: Earth
Old 03-22-2006 , 11:17   Array module and iterating through a map
Reply With Quote #1

Hi there. I've been scripting for a while and have only recently run into this problem with the array module. I've looked around but haven't been able to find any information on how to properly iterate through a map (keytable/hashtable).

I use the following for lists:
Code:
new iKey = list_first(list, 0); for(new i = iKey; i < list_size(list); i++) {     if(list_isfilled(list, iKey))     {         // do whatever     }     iKey = list_next(list, iKey); }

Everything runs fine using this but when it comes to keytables, there is no size() method (clearly) so I cannot do that. I've tried the following code and variations of it but no luck so far. Simply put, it either never enters the loop or runs it infinitely and obviously not executing logic as I intended it to.

Code:
new szKey[512]; map_first(table, "", szKey, strlen(szKey)); while(map_isfilled(table, szKey)) {     // do whatever     map_next(table, szKey, szKey, strlen(szKey)); }

Have also tried it with the null character as the limiting key in map_first but no luck.

Is there any proper way to iterate through a keytable/hashtable? This is essential for my script and I'd really rather not code the entire thing without keytables.

Thanks in advance!
akysiev is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:36.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode