Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
objarray search ?-sorted? ?-start <index>? <obj> <value>

Search the index of an item in the array. returns -1 if it is not found.

...

...

objarray search ?-sorted? <obj> <value>

(if array is sorted it performs a faster binary search).

-start <index> (index>=0 and < length) to start searching from this index (default 0)

e.g.

Code Block
set obj [objarray new_from_to intarray 2 5]
-> 2 3 4 5
objarray search -sorted $obj 4
-> 2
set obj [objarray new intarray -values {1 2 3 -9999 5 -9999 7 8 -9999}]
-> 1 2 3 -9999 5 -9999 7 8 -9999
objarray search -start 0 $obj -9999
-> 3
objarray search -start 4 $obj -9999
-> 5
objarray search -start 6 $obj -9999
-> 8
objarray search -start 9 $obj -9999
-> -1