[sword-devel] Dictionary ordering
dmsmith555 at yahoo.com
Thu Sep 18 07:49:11 MST 2008
Ben Morgan wrote:
> The issue with ordering as I understand it is that if it is in (some
> form of) sorted order, you can use binary search to find entries.
> If you want order retained, it is best to use a genbook - but it won't
> be as efficient, and may not have as good UI support.
> With huge english dictionaries (like Webster's, for instance) this
> becomes very important.
> From BPBible's perspective, dictionary handling is done as follows:
> 1. Read the index of the dictionary and divide by 4 or 6 to get the
> length (depending on the driver)
> 2. Set the virtual list length to the dictionary length
> 3. When any item is displayed in the virtual list, it retrieves it
> from the module.
> 4. When the user starts typing in the text box above, it does a binary
> search to find which item to display.
> 4 is already quite slow enough on big dictionaries - by having it
> unsorted, it would make it quite a lot slower, I imagine.
> All the keys from the module would have to be read in, which takes a
Let me suggest a minor modification of step 4: Remember the location of
the last binary search and use that as the starting point for the next
as a hint. With incremental search, once the place for the first letter
is found, it is faster to start there than all over again.
More information about the sword-devel