* bms_intersect - set intersection */
| 253 | * bms_intersect - set intersection |
| 254 | */ |
| 255 | Bitmapset * |
| 256 | bms_intersect(const Bitmapset *a, const Bitmapset *b) |
| 257 | { |
| 258 | Bitmapset *result; |
| 259 | const Bitmapset *other; |
| 260 | int resultlen; |
| 261 | int i; |
| 262 | |
| 263 | /* Handle cases where either input is NULL */ |
| 264 | if (a == NULL || b == NULL) |
| 265 | return NULL; |
| 266 | /* Identify shorter and longer input; copy the shorter one */ |
| 267 | if (a->nwords <= b->nwords) |
| 268 | { |
| 269 | result = bms_copy(a); |
| 270 | other = b; |
| 271 | } |
| 272 | else |
| 273 | { |
| 274 | result = bms_copy(b); |
| 275 | other = a; |
| 276 | } |
| 277 | /* And intersect the longer input with the result */ |
| 278 | resultlen = result->nwords; |
| 279 | for (i = 0; i < resultlen; i++) |
| 280 | result->words[i] &= other->words[i]; |
| 281 | return result; |
| 282 | } |
| 283 | |
| 284 | /* |
| 285 | * bms_difference - set difference (ie, A without members of B) |
no test coverage detected