Re: Cobol Linear search Vs Perfrom Until
From: Frederico Fonseca (real-email-in-msg-spam_at_email.com)
Date: 07/16/04
- Next message: Colin Campbell: "One last try..."
- Previous message: Richard: "Re: Layout Hell."
- In reply to: docdwarf_at_panix.com: "Re: Cobol Linear search Vs Perfrom Until"
- Next in thread: docdwarf_at_panix.com: "Re: Cobol Linear search Vs Perfrom Until"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 16 Jul 2004 20:24:22 +0100
On 16 Jul 2004 14:06:54 -0400, docdwarf@panix.com wrote:
>In article <3e1gf0pop10e6hn7tikg90ocvd9jopvd7h@4ax.com>,
>Frederico Fonseca <real-email-in-msg-spam@email.com> wrote:
>
>[snip]
>
>>search all
>>when blabla
>> set found to true.
>>end search
>>
>>if found
>> perform varying index from index by -1
>> until index < 1
>> or var(index) not = search-key
>> continue
>> end-perform
>> index now contains the first occurrence of search-key
>>end-if
>>
>>In some cases I would also do a perform varying +1 to get the last
>>occurrence.
>
>Hmmmmm... Mr Fonesca, this approach makes me... uncomfortable. As I
>recall it - and my memory is, admittedly, porous - a SEARCH ALL against a
>table with duplicate entries will return a result for a duplicate key
>whose position is unpredictable; if you have five duplicate entries the
>position returned could be for any of them. If your search returned the
>first occurrence of the key then -1 would bring you into another key's
>data and if the search returned the last a +1 would do the same; it seems
>to me that you'd have to do both -1 and +1 to get the full range... and
>all this peeking and poking about, above and below, makes me...
>uncomfortable.
DD,
as I mentioned on my post
-----
(I had the binary search coded manually, but I think the search all
will also work).
---- I start using this on tables that had over 30000 entries, and as they had duplicates I was using a binary search (manually coded), and then two performs afterwards to get the lower and upper range. Never tried the Search All on this case so I'm not sure if it does. And the real code catters for change of key, and holds the correct index. I have also use the same construct on some VB programs on arrays with 100000+ entries. Works very well. > >But hey... what's a programmer's comfort when compared to the simplicity >of an 'all ya gotta do is' solution? > >DD Frederico Fonseca ema il: frederico_fonseca at syssoft-int.com
- Next message: Colin Campbell: "One last try..."
- Previous message: Richard: "Re: Layout Hell."
- In reply to: docdwarf_at_panix.com: "Re: Cobol Linear search Vs Perfrom Until"
- Next in thread: docdwarf_at_panix.com: "Re: Cobol Linear search Vs Perfrom Until"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]