** Count keys in array part of table 't'. */
| 486 | ** Count keys in array part of table 't'. |
| 487 | */ |
| 488 | static void numusearray (const Table *t, Counters *ct) { |
| 489 | int lg; |
| 490 | unsigned int ttlg; /* 2^lg */ |
| 491 | unsigned int ause = 0; /* summation of 'nums' */ |
| 492 | unsigned int i = 1; /* index to traverse all array keys */ |
| 493 | unsigned int asize = t->asize; |
| 494 | /* traverse each slice */ |
| 495 | for (lg = 0, ttlg = 1; lg <= MAXABITS; lg++, ttlg *= 2) { |
| 496 | unsigned int lc = 0; /* counter */ |
| 497 | unsigned int lim = ttlg; |
| 498 | if (lim > asize) { |
| 499 | lim = asize; /* adjust upper limit */ |
| 500 | if (i > lim) |
| 501 | break; /* no more elements to count */ |
| 502 | } |
| 503 | /* count elements in range (2^(lg - 1), 2^lg] */ |
| 504 | for (; i <= lim; i++) { |
| 505 | if (!arraykeyisempty(t, i)) |
| 506 | lc++; |
| 507 | } |
| 508 | ct->nums[lg] += lc; |
| 509 | ause += lc; |
| 510 | } |
| 511 | ct->total += ause; |
| 512 | ct->na += ause; |
| 513 | } |
| 514 | |
| 515 | |
| 516 | /* |
no test coverage detected