* Generates the tuple that is lexicographically one greater than the current * n-tuple in "curr", with the restriction that the i-th element of "curr" is * less than the i-th element of "span". * * Returns -1 if no next tuple exists, else the subscript position (0..n-1) * corresponding to the dimension to advance along. * * We assume caller has validated dimensions, so overflow is impossibl
| 197 | * We assume caller has validated dimensions, so overflow is impossible |
| 198 | */ |
| 199 | int |
| 200 | mda_next_tuple(int n, int *curr, const int *span) |
| 201 | { |
| 202 | int i; |
| 203 | |
| 204 | if (n <= 0) |
| 205 | return -1; |
| 206 | |
| 207 | curr[n - 1] = (curr[n - 1] + 1) % span[n - 1]; |
| 208 | for (i = n - 1; i && curr[i] == 0; i--) |
| 209 | curr[i - 1] = (curr[i - 1] + 1) % span[i - 1]; |
| 210 | |
| 211 | if (i) |
| 212 | return i; |
| 213 | if (curr[0]) |
| 214 | return 0; |
| 215 | |
| 216 | return -1; |
| 217 | } |
| 218 | |
| 219 | /* |
| 220 | * ArrayGetIntegerTypmods: verify that argument is a 1-D cstring array, |
no outgoing calls
no test coverage detected