Re: Determining item number matching "x" in a list
Re: Determining item number matching "x" in a list
- Subject: Re: Determining item number matching "x" in a list
- From: Emmanuel <email@hidden>
- Date: Fri, 21 Mar 2003 15:55:47 +0100
I have put on line a plot that compares different algorithms to
retrieve the index of a given string in a list. Such as: given
"March" and the list of the months {"January", etc.}, return 3.
Credits are mainly to Steve Cunningham and Nigel Garvey, but other
contributors helped also.
I could not yet find some time to test Kai's suggestion. (I have the
full tester script available, if someone wants to give it a few
minutes).
The three methods tested were:
"Binary": dichotomic use of "is in"
"Brute": mere comparison in loop
"TIDs": use tid's to find offset of item in list made into string,
then "count paragraphs" to count rank.
We tested with a list of 20 items. The list can only contain strings
that do not contain the return character.
The graphs were made for OS9 and for OSX. They plot the time required
vs the rank of the item (for instance, the "Brute" method's plot is
practically a straight increasing line).
The graphs show that TID's are better, and that OSX is more than
twice faster than OS9.
The plots are visible at:
<
http://www.satimage.fr/software/images/GetitemOS9OSX.jpg>
Emmanuel
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.