Tony,
The method of going through a table by halves is very effective and fast
where a number (*N*) lies inside a given range.
Now how you could do this using TiddlyWiki is the challenge!
The below simple method can look up a table of a million range entries in
milliseconds.
1. Count the number of entries in your table. Say you have 10,000 post
codes.
Likely the table will be less than 1,000 entries as they are ranges -
let us say it is 1,000 ranges (X)
First Line is 0 (FL) : FL = 0
Note the post code entry that is in the middle position of this table -
the X/2 = 500th entry in the table (Integer value)
This is the Search Line(SL) : SL = INT(X/2)
2. Check if your number (*N*) is
greater than the start value of this middle entry's post code range
AND less than the end value of this range.
If it is, you have found the correct range. - Stop here.
If not ...
3a. Check if the post code *N* is NOT in any range in your table (needed
as you narrow down your search)
If FL=SL then the Code is Missing - Stop here.
3b. If *N* is greater than the start value of the range
Make FL = SL
check against the higher next half point table entry position: (FL +
X)/2 = 750 (Rounded value)
Repeat step #2
3b. ELSE (meaning *N* is less than the start value of the range)
Make X = SL
check against the lower next half point table entry position: (FL +
X)/2 = 250 (Integer value)
and Repeat step #2
4. Continue until you reach the end point - I believe 2^10 calculations
(1,024) for this size of table.
I doubt you will end up doing it this way, as TiddlyWiki out of the box
doesn't seem to be geared for this kind of manipulation.
Still, it was fun laying you the logic for you!
Cheers
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/e76db365-ffaa-4afe-8580-4ad3c433b16b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.