AnsweredAssumed Answered

vrf Just for interest- Array manipulation

Question asked by VRFuser on Nov 15, 2001
Howdy from Sunny Devon!

Just thought you may be interested - I saw some discussion about looking
for a match in an array.  Unfortunately the comparator method wasn't going
to help me so I contrived a 'three step' method which uses VEE's automatic
data-promotion:

inputs: text array TxtAry and the name for comparison, Name

first, create an array of 'find' using strPosStr(TxtAry,Name)         (
with strDown/Up if needed )

this provides a zero element only if there is a match and it starts at the
beginning


next create an array of 'matchlen' using strLen(TxtAry) - strLen(Name)

this provides a zero element only if there is a match of the string length


finally OR the results using min(Find OR MatchLen) which is zero only if
there is a zero in both arrays at the same element.


After congratulating myself on this I wondered "is this really any quicker
with VEE 6?".  So I decided I'd better try it.  Good news, it is!  For the
run I compared Name against a TxtAry of 300 elements and ran the comparison
1000 times in VEE 6.01 on an HP PIII 500 MHz machine running NT4 SP6:

tricky array math method: 1.45 ms per search
FOR each element Name == TxtAry[element]: 16.5 ms per search

i.e. an order of magnitude improvement.

Hope that may be of interest.

P.S. I was doing this to fix a minor irritation with the VEE Object
Libraries I've created ( and you can find on my website ) - look out for
the next siet update for the new version.

Mike Watts


_______________________________________________________________________

  Michael Watts, Consultant                                 PO Box 92
  on the web: www.PreciselySo.Co.UK                      Exeter,Devon
  e-mail: MJWC@PreciselySo.Co.UK                              England     
  tel: 07714 339 729                                          EX4 2YY
_______________________________________________________________________
---------------------------------------------------------------------
This is the "vrf" maillist, managed by Majordomo.  To send messages to
this maillist, just email to "vrf@lvld.agilent.com".  Subscriptions and
unsubscriptions are done through the address "vrf-request@lvld.agilent.com".
If you need details, just send a message containing the text "help"
to "vrf-request@lvld.agilent.com".
---------------------------------------------------------------------

Outcomes