logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
(BUG) HashSet GetNthKey for linux plugin

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development
View previous topic :: View next topic  
Author Message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Sat Oct 22, 2005 0:20    Post subject: (BUG) HashSet GetNthKey for linux plugin Reply with quote

So, I wanted to get the last key in the hashset. I tried doing a getsize then using that to run a GetNthKey - always failed to return.. after bangin my head against the wall I tested the GetNthKey function and I could successfully trample through the hashset, retrieving values and keys - but when trying any GetNthKey with 0,1,2,3,4,5 etc as arguments - it still fails.

From that quick test, it suggests GetNthKey in the hashset plugin for linux is bugged.

Can anyone else verify this?
Back to top
View user's profile Send private message
weldieran



Joined: 05 Aug 2005
Posts: 71

PostPosted: Mon Dec 05, 2005 20:41    Post subject: Reply with quote

OK - Well i guess nobody else realizes this, but its confirmed, GetNthKey does not work in HashSet for linux.

It was never implemented it seems, here's the code for it:

Log(0,"Ack! GetNthKey called!\n");

Laughing

[edit]
this is most likely due to the standard library 'map' function that HashSet for linux uses. To my limited knowledge, 'map' is incapable of such a retrieval.
Back to top
View user's profile Send private message
NoMercy



Joined: 03 Jan 2005
Posts: 123
Location: UK

PostPosted: Mon Dec 19, 2005 4:18    Post subject: Reply with quote

Checked the references and various other bits, there does seem to be no easy way to retrieve a n'th element from map, quick and dirty solution would be an iterator and just count though to find the one your after, not fast but would at least get it working.

Possibilities to improve speed, things like taking end() as the start point if the index is greater than half of the map size etc.

Code:

map<string, int>::iterator mi;

mi = m->begin();
while(i--) mi++;

cout << mi->first << "=" << mi->second << "\t";


I would drag the code up, write it, and post it for whoever, but It's late, I'm jetlagged and I've got work tomorrow :S
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Linux development All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group