[sword-devel] Counting Keys in a Module

mmital mitalmanu at hotmail.com
Mon Apr 21 16:57:58 MST 2008


Thanks for the reply. Very much appreciated. Mr. Smith's method seems to be very neat and I will try to implement that. I needed the count method because a virtual List Control that displays the lexicon needs to know number of entries in advance.
Right now I am getting the count using a slightly improved brute force:



int GetNumEntries()
{

// initial guess

int high = 10000, low = 0, mid = (high + low)/2;

while ( high - low > 1 ) {

pModule->setPosition(sword::TOP);   pModule->increment(mid);

if( pModule->Error() )     high = mid;

else low = mid;


mid = (high + low)/2; 

}

return high;

}


I am not sure what are the dangers in doing this (if any).


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.crosswire.org/pipermail/sword-devel/attachments/20080421/e18ea278/attachment.html 


More information about the sword-devel mailing list