LoginLogin
Might make SBS readonly: thread

faster looping

Root / Submissions / [.]

DFrostCreated:
the most common way to loop through an array is this:
DEF SEARCH(ARRAY,LOOK)
FOR I = 0 TO LEN(ARRAY)-1
 IF ARRAY[I]==LOOK THEN RETURN I
NEXT
END
but this is very inefficient speed-wise. but an alternative, which is 25% faster is bilinear search:
DEF BILINEARSEARCH(ARRAY,LOOK)
 VAR L = LEN(ARRAY)-1,L2=L/2
 FOR I = 0 TO L2
  IF ARRAY[L2+I]==LOOK THEN RETURN L2+I
  IF ARRAY[L2-I]==LOOK THEN RETURN L2-I
 NEXT
 IF ARRAY[L]==LOOK THEN RETURN L
 RETURN -1
 END

this is a parody

Replying to:DFrost
this is a parody
??

Replying to:DFrost
this is a parody
you referenced this and called it a parody

Replying to:DFrost
this is a parody
I called super search a parody of this page.

Replying to:DFrost
this is a parody
OH OK!