in reply to Poor Person's Database
To search a file such as you described non-linearly you need to either build an index structure for it (which tells your program, say, what byte to seek to for search terms beginning with the letter 'k') or perform a binary search on the file itself while taking the irregular record structure into account. The latter approach is kind of fun to program; you seek to the middle of the file, cruise forward to the next newline, and then read the next line to see what keyword you are on. Adjust the target forwards or backwards and seek again.
Note that I said it was fun to program, not blindingly fast :) But it should be faster than a linear search for most data.
|
---|