MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / numusearray

Function numusearray

libraries/AP_Scripting/lua/src/ltable.c:266–289  ·  view source on GitHub ↗

** Count keys in array part of table 't': Fill 'nums[i]' with ** number of keys that will go into corresponding slice and return ** total number of non-nil keys. */

Source from the content-addressed store, hash-verified

264** total number of non-nil keys.
265*/
266static unsigned int numusearray (const Table *t, unsigned int *nums) {
267 int lg;
268 unsigned int ttlg; /* 2^lg */
269 unsigned int ause = 0; /* summation of 'nums' */
270 unsigned int i = 1; /* count to traverse all array keys */
271 /* traverse each slice */
272 for (lg = 0, ttlg = 1; lg <= MAXABITS; lg++, ttlg *= 2) {
273 unsigned int lc = 0; /* counter */
274 unsigned int lim = ttlg;
275 if (lim > t->sizearray) {
276 lim = t->sizearray; /* adjust upper limit */
277 if (i > lim)
278 break; /* no more elements to count */
279 }
280 /* count elements in range (2^(lg - 1), 2^lg] */
281 for (; i <= lim; i++) {
282 if (!ttisnil(&t->array[i-1]))
283 lc++;
284 }
285 nums[lg] += lc;
286 ause += lc;
287 }
288 return ause;
289}
290
291
292static int numusehash (const Table *t, unsigned int *nums, unsigned int *pna) {

Callers 1

rehashFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected