lstlei_c

 Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input Detailed_Output Parameters Exceptions Files Particulars Examples Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

```   SpiceInt lstlei_c ( SpiceInt            x,
SpiceInt            n,
ConstSpiceInt     * array )
```

#### Abstract

```
Given a number x and an array of non-decreasing numbers,
find the index of the largest array element less than or equal
to x.
```

```
None.
```

#### Keywords

```
SEARCH,  ARRAY

```

#### Brief_I/O

```
VARIABLE  I/O  DESCRIPTION
--------  ---  --------------------------------------------------
x          I   Value to search against
n          I   Number elements in array
array      I   Array of possible lower bounds

The function returns the index of the last element of array that
is less than or equal to x.
```

#### Detailed_Input

```
x       Integer.

n       Total number of elements in array.

array   Array of integers which forms a non-decreasing sequence.
The elements of array need not be distinct.

```

#### Detailed_Output

```
The function returns the index of the highest-indexed element in the
input array that is less than or equal to x.  The routine assumes
the array elements are sorted in non-decreasing order.

Indices range from 0 to n-1.

If all elements of array are greater than x, this routine returns
the value -1.
```

```
None.
```

#### Exceptions

```
Error free.

1) In the case that n is input with value less than or equal
to zero, the function returns -1.

2) If the input array is not sorted in increasing order, the
output of this routine are undefined.  No error is signaled.
```

```
None.
```

#### Particulars

```
Note:  If you need to find the first element of the array that
is greater than x, simply add 1 to the result returned
by this function and check to see if the result is
within the array bounds given by n.
```

#### Examples

```
1)  Let array be assigned the following values:

array = -2;
array = -2;
array =  0;
array =  1;
array =  1;
array = 11;

The table below demonstrates the behavior of lstlei_c:

Call                       Returned Value
=========================            ==============
lstlei_c ( -3, 6, array )                -1

lstlei_c ( -2, 6, array )                 1

lstlei_c (  0, 6, array )                 2

lstlei_c (  1, 6, array )                 4

lstlei_c ( 12, 6, array )                 5
```

#### Restrictions

```
If the sequence of elements in array is not non-decreasing,
the program will run to completion but the index found will
not mean anything.
```

```
None.
```

#### Author_and_Institution

```
N.J. Bachman    (JPL)
W.L. Taber      (JPL)
```

#### Version

```
-CSPICE Version 1.0.0, 10-JUL-2002 (NJB) (WLT)
```

#### Index_Entries

```
last integer element less_than_or_equal_to
```
`Wed Apr  5 17:54:38 2017`