Suppose I have a large list. Very large list. Then I want to search
for an item in that string:
% lsearch $list "string"
Now, suppose I have many lists instead. One list contains all the items
that begin with the letter a, another list contains all the items that
begin with the letter b, another list contains all the items that begin
with the letter c, and so on. Then I see what the first character in "string" is and only search for it in the one corresponding list.
Would that be faster? I somehow suspect the answer is 'no.'
Bonus question: what about sqlite operations? Would they be faster if
I had one separate table for each initial letter/character?
Suppose I have a large list. Very large list. Then I want to search
for an item in that string:
% lsearch $list "string"
Now, suppose I have many lists instead. One list contains all the items
that begin with the letter a, another list contains all the items that
begin with the letter b, another list contains all the items that begin
with the letter c, and so on. Then I see what the first character in
"string" is and only search for it in the one corresponding list.
Would that be faster? I somehow suspect the answer is 'no.'
Bonus question: what about sqlite operations? Would they be faster if
I had one separate table for each initial letter/character?
TIA
Depending very much on what you want to do with the result from your
search, and speed is your primary concern, there may be another way to >approach this...
If you're just checking for whether a word exists in some word list,
have you considered creating array variables ?
On Thu, 26 Sep 2024 18:46:36 -0700, Shaun Deacon wrote:
Depending very much on what you want to do with the result from your >>search, and speed is your primary concern, there may be another way to >>approach this...
If you're just checking for whether a word exists in some word list,
have you considered creating array variables ?
Right now, at this very exact moment, I am toying with a real time
search box, and by "real time" I mean the search output changes with
every new character typed into the user input widget. But I'm always searching for all kinds of stuff when I code. It's a very common need.
Interesting idea with the array variables. Thank you for your input.
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 991 |
Nodes: | 10 (0 / 10) |
Uptime: | 119:52:19 |
Calls: | 12,958 |
Files: | 186,574 |
Messages: | 3,265,641 |