Use a binaryincluded text file
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Use a binaryincluded text file
Hehe, if I were still trying to solve this one after 8 years I'd seriously consider hanging up my lily pad! FindString was available at the time too but was rejected for speed reasons. If I were doing this today I'd spend 3 minutes making a map and then go watch some funny cats on YouTube. Interestingly enough though, even today I'm having to do something similar. I'm working with LZW compression and I have to look at a lot of strings, do one thing if I've seen a string before and another if I haven't. I'm using a map of course.
BERESHEIT
Re: Use a binaryincluded text file
Hi netmaestro,
Are you suggesting that a map is faster than you very neat 'binary chop' or is it just a whole lot more convenient?
Are you suggesting that a map is faster than you very neat 'binary chop' or is it just a whole lot more convenient?
DE AA EB
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
Re: Use a binaryincluded text file
Both actually. The binary search I'm using for the dictionary might take an average of 7-10 tests before it finds the searched string, and maybe up to 17. While that's quite fast it can't compete with a map. The map generates a hash for the string and the result is the address of an array element - it just goes right to it with no searching (provided the hash isn't a collision, which will slow it down slightly) Also, the binary search requires that all elements be sorted prior to searching, which makes adding new words slow and tedious as they have to be inserted just where they belong. Not so with a map.
One other consideration is the size of the list. The larger the dataset the greater the speed gain with a map.
One other consideration is the size of the list. The larger the dataset the greater the speed gain with a map.
BERESHEIT
Re: Use a binaryincluded text file
> Once again, PB has to be correct
I only replied since NM replied the other day. Didn't
mean to annoy or piss you off. And since you said
"once again", I assume I've done it to you in the
past, rsts. If so, I apologize.
I only replied since NM replied the other day. Didn't
mean to annoy or piss you off. And since you said
"once again", I assume I've done it to you in the
past, rsts. If so, I apologize.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
Re: Use a binaryincluded text file
Hi netmaestro,
Thank you, very much, for taking the trouble to explain the difference between the two.
Thank you, very much, for taking the trouble to explain the difference between the two.

DE AA EB