This portal is to open public enhancement requests against IBM Z Software products. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).
We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:
Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,
Post an idea.
Get feedback from the IBM team and other customers to refine your idea.
Follow the idea through the IBM Ideas process.
Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.
IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.
ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.
this was delivered as part of APAR PI75582 / PTF UI44364
BINSEARCH performs a binary search, using a simple compare, of an array for a specified key value and returns a size_t value that is the relative index of the key value within the array (or zero if the value is not found in the array).
The syntax of BINSEARCH is
BINSEARCH( x, y, [ n, [ m ] ] )
The argument x must be a one-dimensional array, and if it is an array of NONVARYING BIT, then it must be aligned. The elements of the array must be in ascending order.
The argument y specifies the key value to be searched for.
The optional argument n specifies the index of the first array element to be examined. It defaults to LBOUND( x ).
The optional argument m specifies the number of array elements - starting with the nth - to be examined. It defaults to HBOUND(x) - n + 1.
The elements of the array x and the value must satisfy one of the following:
Both must be computational and neither may be COMPLEX
Both must be POINTERs
Both must be HANDLEs to the same structure type
Both must be ORDINALs of the same type
If y is not found in the array, then the value zero is returned. If it is found in the array, the relative index of that value within the array is returned. The relative index is the index if the array had a lower bound of 1. So, the true index would be the returned value plus LBOUND(x)-1. For example
If the array x has a lower bound of 0 and upper bound of 11, then the value returned will range from 0 to 12 inclusive, and if the returned value is non-zero, the true index of the found value is the returned value minus 1.
If the array x has a lower bound of -12 and an upper bound of 12, then the returned value will range from 0 to 25 inclusive, and if the returned value is non-zero, the true index of the found value is the returned value minus 13.
BINSEARCHX performs a binary search, using a specified compare function, of an array for a specified key value and returns a size_t value that is the relative index of the key value within the array (or zero if the value is not found in the array).
The syntax of BINSEARCHX is
BINSEARCHX( x, p, f, [ n, [ m ] ] )
The argument x must be a one-dimensional array, and if it is an array of NONVARYING BIT, then it must be aligned. The elements of the array must be in ascending order.
The argument p specifies the address of the key value to be searched for.
The argument f specifies the function that will be invoked to perform all the required comparisons.
The optional argument n specifies the index of the first array element to be examined. It defaults to LBOUND( x ).
The optional argument m specifies the number of array elements - starting with the nth - to be examined. It defaults to HBOUND(x) - n + 1.
The function f is passed 2 POINTER BYVALUE arguments: the first is the address of an array element and the second is the value of p - the address of the key value to be searched for.
It must return BYVALUE a FIXED BIN(31) value that is -1, 0, or +1 depending on whether the value of the array element is less than, equal, or greater than, respectively, the value of the key element
The function f must have the OPTLINK linkage
If y is not found in the array, then the value zero is returned. If it is found in the array, the relative index of that value within the array is returned. The relative index is the index if the array had a lower bound of 1. So, the true index would be the returned value plus LBOUND(x)-1. See the description of the BINSEARCH built-in functions for some examples of how this value can vary with the bounds of the array.
This would be useful