View previous topic :: View next topic |
Author |
Message |
weldieran
Joined: 05 Aug 2005 Posts: 71
|
Posted: Sat Oct 22, 2005 0:20 Post subject: (BUG) HashSet GetNthKey for linux plugin |
|
|
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 |
|
|
weldieran
Joined: 05 Aug 2005 Posts: 71
|
Posted: Mon Dec 05, 2005 20:41 Post subject: |
|
|
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");
[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 |
|
|
NoMercy
Joined: 03 Jan 2005 Posts: 123 Location: UK
|
Posted: Mon Dec 19, 2005 4:18 Post subject: |
|
|
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 |
|
|
|
|
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
|