diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /pkg/utilities/nttools/lib/movenulls.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/lib/movenulls.x')
-rw-r--r-- | pkg/utilities/nttools/lib/movenulls.x | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/lib/movenulls.x b/pkg/utilities/nttools/lib/movenulls.x new file mode 100644 index 00000000..5e961d20 --- /dev/null +++ b/pkg/utilities/nttools/lib/movenulls.x @@ -0,0 +1,35 @@ +# MOVENULLS -- Move all null elements to the end of the index array +# +# This procedure rearranges an array of row indices so that all rows with +# nulls in a particular column are moved to the end of the index array. +# The position of the nulls in the column is indicated by an array of null +# flags, whose length might be greater than the length of the array of +# indices, i.e., only a subset of the rows in a table might be in the index +# array. +# +# B.Simon 15-Dec-87 First Code + +int procedure movenulls (nindex, nulflg, index) + +int nindex # i: Number of indices +bool nulflg[ARB] # i: Array of null flags +int index[ARB] # io: Array of row indices +#-- +int nelem, idx, jdx + +begin + nelem = nindex + + do idx = nindex, 1, -1 { + jdx = index[idx] + if (nulflg[jdx]) { + if (nelem != idx) { + index[idx] = index[nelem] + index[nelem] = jdx + } + nelem = nelem - 1 + } + } + + return (nelem) +end |