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: John Delacour <email@hidden>
- Date: Fri, 14 Mar 2003 15:36:08 +0000
- Mac-eudora-version: 6.0a11
At 5:49 am -0500 14/3/03, Steve Cunningham wrote:
Emmanuel wrote:
...
(follow-up of my previous mail)
NG's "getindex" requires 170 +or- 25 microseconds
My "IndexOfItem" requires 809 +or- 37 microseconds
Wow! The binary search really cuts it down for a long list. Two
observations:
- "... item is in the list" must fly... how hard could it be to return
which item ? :-)
This script writes 32000 random ascii characters to a file. It then
loops through every character (line) and reports the index in the
list of every "a" it finds.
The second loop takes about half a second on my machine, or 19
seconds if I loop though a million items.
do shell script "perl -e '
$f = qq~/tmp/junk.txt~ ;
open F, qq~>$f~ ;
for (1..32000) {
$_ = 33 + int rand(223) ; print F chr() .$/ }'"
do shell script "perl -e '
$f = qq~/tmp/junk.txt~ ; open F, qq~$f~ ;
for (<F>) {
$i++ ;
/a/ and print qq~$i$/~ }'"
JD
_______________________________________________
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.