xsarray.c
Go to the documentation of this file.
1 
2 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without modification,
6 // are permitted provided that the following conditions are met:
7 //
8 // 1. Redistributions of source code must retain the above copyright notice,
9 // this list of conditions, and the following disclaimer.
10 //
11 // 2. Redistributions in binary form must reproduce the above copyright notice,
12 // this list of conditions, and the following disclaimer in the documentation
13 // and/or other materials provided with the distribution.
14 //
15 // 3. Neither the names of the copyright holders nor the names of their contributors
16 // may be used to endorse or promote products derived from this software without
17 // specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
20 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
22 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
24 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
26 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
28 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
29 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
30 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
31 //
32 
33 
34 // Copyright (c) 2003-2021 Xsens Technologies B.V. or subsidiaries worldwide.
35 // All rights reserved.
36 //
37 // Redistribution and use in source and binary forms, with or without modification,
38 // are permitted provided that the following conditions are met:
39 //
40 // 1. Redistributions of source code must retain the above copyright notice,
41 // this list of conditions, and the following disclaimer.
42 //
43 // 2. Redistributions in binary form must reproduce the above copyright notice,
44 // this list of conditions, and the following disclaimer in the documentation
45 // and/or other materials provided with the distribution.
46 //
47 // 3. Neither the names of the copyright holders nor the names of their contributors
48 // may be used to endorse or promote products derived from this software without
49 // specific prior written permission.
50 //
51 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
52 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
53 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
54 // THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
55 // SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
56 // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY OR
58 // TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
59 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.THE LAWS OF THE NETHERLANDS
60 // SHALL BE EXCLUSIVELY APPLICABLE AND ANY DISPUTES SHALL BE FINALLY SETTLED UNDER THE RULES
61 // OF ARBITRATION OF THE INTERNATIONAL CHAMBER OF COMMERCE IN THE HAGUE BY ONE OR MORE
62 // ARBITRATORS APPOINTED IN ACCORDANCE WITH SAID RULES.
63 //
64 
65 #include "xsarray.h"
66 #include <stdlib.h>
67 #include <string.h>
68 #include "xsdebugcounters.h"
69 
79 #define elemSize(thisArray) (thisArray->m_descriptor->itemSize)
80 #define elemAtX(b, i, thisArray) ((void*)(((char*) (b))+((i)*elemSize(thisArray))))
81 #define elemAt(b, i) elemAtX(b, i, thisArray)
82 
84 #ifdef DOXYGEN
85 
91  void XsArray_constructDerived(void* thisPtr, XsSize count, void const* src);
92 #endif
93 
102 void XsArray_construct(void* thisPtr, XsArrayDescriptor const* const descriptor, XsSize count, void const* src)
103 {
104  XsArray* thisArray = (XsArray*) thisPtr;
105  *((XsArrayDescriptor const**) &thisArray->m_descriptor) = descriptor;
106  *((XsSize*) &thisArray->m_size) = count;
107 
108  if (thisArray->m_size)
109  {
110  // init to size
111  *((void**) &thisArray->m_data) = malloc(thisArray->m_size * elemSize(thisArray));
113 
114  // init the configurations
115  if (src)
116  {
117  if (thisArray->m_descriptor->rawCopy)
118  thisArray->m_descriptor->rawCopy(thisArray->m_data, src, thisArray->m_size, thisArray->m_descriptor->itemSize);
119  else
120  {
121  XsSize i;
122  assert(thisArray->m_descriptor->itemCopyConstruct);
123  for (i = 0; i < thisArray->m_size; ++i)
124  thisArray->m_descriptor->itemCopyConstruct(elemAt(thisArray->m_data, i), elemAt(src, i));
125  }
126  }
127  else if (thisArray->m_descriptor->itemConstruct)
128  {
129  XsSize i;
130  for (i = 0; i < thisArray->m_size; ++i)
131  thisArray->m_descriptor->itemConstruct(elemAt(thisArray->m_data, i));
132  }
133  }
134  else
135  *((void**) &thisArray->m_data) = 0;
136  *((XsSize*) &thisArray->m_reserved) = thisArray->m_size;
137  *((XsSize*) &thisArray->m_flags) = XSDF_Managed;
138 }
139 
144 void XsArray_copyConstruct(void* thisPtr, void const* src)
145 {
146  XsArray* thisArray = (XsArray*) thisPtr;
147  XsArray const* srcArray = (XsArray const*) src;
148  assert(srcArray);
149  XsArray_construct(thisArray, srcArray->m_descriptor, srcArray->m_size, srcArray->m_data);
150 }
151 
157 void XsArray_destruct(void* thisPtr)
158 {
159  XsArray* thisArray = (XsArray*) thisPtr;
160  if (thisArray->m_data && (thisArray->m_flags & XSDF_Managed))
161  {
162  XsSize i;
163  // clear contents
164  if (thisArray->m_descriptor->itemDestruct)
165  for (i = 0; i < thisArray->m_reserved; ++i)
166  thisArray->m_descriptor->itemDestruct(elemAt(thisArray->m_data, i));
167  free((void*) thisArray->m_data);
169  }
170  // init to 0
171  *((void**) &thisArray->m_data) = 0;
172  *((XsSize*) &thisArray->m_size) = 0;
173  *((XsSize*) &thisArray->m_reserved) = 0;
174  *((XsSize*) &thisArray->m_flags) = (thisArray->m_flags & (XSDF_Managed | XSDF_FixedSize));
175 }
176 
186 void XsArray_assign(void* thisPtr, XsSize count, void const* src)
187 {
188  XsSize i;
189  XsArray* thisArray = (XsArray*) thisPtr;
190 
191  // check if we need to reallocate
192  if (count > thisArray->m_reserved)
193  {
194  assert(thisArray->m_flags & XSDF_Managed);
195 
196  if (thisArray->m_data)
197  XsArray_destruct(thisArray);
198  XsArray_construct(thisArray, thisArray->m_descriptor, count, src);
199  return;
200  }
201 
202  // no reallocation necessary, clear excess objects
203  if (thisArray->m_descriptor->itemDestruct)
204  for (i = count; i < thisArray->m_size; ++i)
205  thisArray->m_descriptor->itemDestruct(elemAt(thisArray->m_data, i));
206 
207  if (src)
208  {
209  if (thisArray->m_descriptor->rawCopy)
210  thisArray->m_descriptor->rawCopy(thisArray->m_data, src, count, thisArray->m_descriptor->itemSize);
211  else
212  {
213  for (i = 0; i < count; ++i)
214  thisArray->m_descriptor->itemCopy(elemAt(thisArray->m_data, i), elemAt(src, i));
215  }
216  }
217 
218  *((XsSize*) &thisArray->m_size) = count;
219 }
220 
227 void XsArray_resize(void* thisPtr, XsSize count)
228 {
229  XsArray* thisArray = (XsArray*) thisPtr;
230  if (thisArray->m_size == count)
231  return;
232  if (thisArray->m_size == 0)
233  {
234  XsArray_assign(thisArray, count, 0);
235  return;
236  }
237  if (count < thisArray->m_size)
238  {
239  XsArray_erase(thisArray, count, thisArray->m_size - count);
240  return;
241  }
242  if (count > thisArray->m_reserved)
243  XsArray_reserve(thisArray, count);
244  *((XsSize*) &thisArray->m_size) = count;
245 }
246 
256 void XsArray_reserve(void* thisPtr, XsSize count)
257 {
258  XsArray* thisArray = (XsArray*) thisPtr;
259  XsArray tmp = { 0, thisArray->m_size, 0, XSDF_Managed, thisArray->m_descriptor };
260  XsSize i;
261 
262  if (count && count <= thisArray->m_reserved)
263  return;
264 
265  if (count < thisArray->m_size)
266  count = thisArray->m_size;
267 
268  if (count == thisArray->m_reserved)
269  return;
270 
271  if (!(thisArray->m_flags & XSDF_Managed))
272  {
273  // attempting this on an unmanaged list is ignored silently
274  return;
275  }
276 
277  if (!count)
278  {
279  XsArray_destruct(thisArray);
280  return;
281  }
282 
283  *((XsSize*) &tmp.m_reserved) = count;
284 
285  // init to size
286  *((void**) &tmp.m_data) = malloc(tmp.m_reserved * elemSize(thisArray));
287  assert(tmp.m_data);
288  if (!tmp.m_data)
289  return;
291 
292  if (thisArray->m_descriptor->itemConstruct)
293  for (i = 0; i < tmp.m_reserved; ++i)
294  thisArray->m_descriptor->itemConstruct(elemAt(tmp.m_data, i));
295 
296  for (i = 0; i < thisArray->m_size; ++i)
297  thisArray->m_descriptor->itemSwap(elemAt(thisArray->m_data, i), elemAt(tmp.m_data, i));
298 
299  XsArray_destruct(thisArray);
300  XsArray_swap(thisArray, &tmp);
301 }
302 
305 void XsArray_copy(void* thisPtr, void const* src)
306 {
307  XsArray* thisArray = (XsArray*) thisPtr;
308  XsArray const* srcArray = (XsArray const*) src;
309 
310  if (srcArray == thisArray)
311  return;
312  XsArray_assign(thisArray, srcArray->m_size, srcArray->m_data);
313 }
314 
319 void XsArray_append(void* thisPtr, void const* other)
320 {
321  XsSize i;
322  XsArray* thisArray = (XsArray*) thisPtr;
323  XsArray const* otherArray = (XsArray const*) other;
324 
325  if (otherArray->m_size == 0)
326  return;
327 
328  if (otherArray == thisArray)
329  {
330  if (thisArray->m_size + thisArray->m_size > thisArray->m_reserved)
331  XsArray_reserve(thisArray, thisArray->m_size + thisArray->m_size); // maybe reserve more here?
332 
333  if (thisArray->m_descriptor->rawCopy)
334  thisArray->m_descriptor->rawCopy(elemAt(thisArray->m_data, thisArray->m_size), thisArray->m_data, thisArray->m_size, thisArray->m_descriptor->itemSize);
335  else
336  {
337  for (i = 0; i < thisArray->m_size; ++i)
338  thisArray->m_descriptor->itemCopy(elemAt(thisArray->m_data, i + thisArray->m_size), elemAt(thisArray->m_data, i));
339  }
340 
341  *((XsSize*) &thisArray->m_size) = thisArray->m_size + thisArray->m_size;
342  return;
343  }
344 
345  if (thisArray->m_size == 0)
346  {
347  XsArray_copy(thisArray, otherArray);
348  return;
349  }
350 
351  if (thisArray->m_size + otherArray->m_size > thisArray->m_reserved)
352  XsArray_reserve(thisArray, thisArray->m_size + otherArray->m_size); // maybe reserve more here?
353 
354  if (thisArray->m_descriptor->rawCopy)
355  thisArray->m_descriptor->rawCopy(elemAt(thisArray->m_data, thisArray->m_size), otherArray->m_data, otherArray->m_size, thisArray->m_descriptor->itemSize);
356  else
357  {
358  for (i = 0; i < otherArray->m_size; ++i)
359  thisArray->m_descriptor->itemCopy(elemAt(thisArray->m_data, i + thisArray->m_size), elemAt(otherArray->m_data, i));
360  }
361 
362  *((XsSize*) &thisArray->m_size) = thisArray->m_size + otherArray->m_size;
363 }
364 
372 void XsArray_insert(void* thisPtr, XsSize index, XsSize count, void const* src)
373 {
374  XsSize s;
375  XsArray* thisArray = (XsArray*) thisPtr;
376  XsSize i, d = count;
377  if (thisArray->m_size + count > thisArray->m_reserved)
378  XsArray_reserve(thisArray, ((thisArray->m_size + count) * 3) / 2); // we reserve 50% more space here to handle multiple sequential insertions efficiently
379 
380  // fix index if beyond end of list
381  if (index > thisArray->m_size)
382  index = thisArray->m_size;
383 
384  // move items to the back by swapping
385  for (i = thisArray->m_size - 1; i >= index && i < thisArray->m_size; --i)
386  thisArray->m_descriptor->itemSwap(elemAt(thisArray->m_data, i), elemAt(thisArray->m_data, i + d));
387 
388  // copy items to the array
389  if (thisArray->m_descriptor->rawCopy)
390  thisArray->m_descriptor->rawCopy(elemAt(thisArray->m_data, index), src, count, thisArray->m_descriptor->itemSize);
391  else
392  {
393  for (s = 0; s < count; ++s)
394  thisArray->m_descriptor->itemCopy(elemAt(thisArray->m_data, s + index), elemAt(src, s));
395  }
396 
397  // update size
398  *((XsSize*) &thisArray->m_size) = thisArray->m_size + count;
399 }
400 
408 void XsArray_swap(void* a, void* b)
409 {
410  XsArray* aArray = (XsArray*) a;
411  XsArray* bArray = (XsArray*) b;
412 
413  if (!aArray->m_data && !bArray->m_data)
414  return;
415  if ((!aArray->m_data || (aArray->m_flags & XSDF_Managed)) && (!bArray->m_data || (bArray->m_flags & XSDF_Managed)))
416  {
417  // administrative swap
418  XsArray tmp;
419  *((void**) &tmp.m_data) = aArray->m_data;
420  *((void**) &aArray->m_data) = bArray->m_data;
421  *((void**) &bArray->m_data) = tmp.m_data;
422 
423  *((XsSize*) &tmp.m_size) = aArray->m_size;
424  *((XsSize*) &aArray->m_size) = bArray->m_size;
425  *((XsSize*) &bArray->m_size) = tmp.m_size;
426 
427  *((XsSize*) &tmp.m_reserved) = aArray->m_reserved;
428  *((XsSize*) &aArray->m_reserved) = bArray->m_reserved;
429  *((XsSize*) &bArray->m_reserved) = tmp.m_reserved;
430 
431  *((XsSize*) &tmp.m_flags) = aArray->m_flags;
432  *((XsSize*) &aArray->m_flags) = bArray->m_flags;
433  *((XsSize*) &bArray->m_flags) = tmp.m_flags;
434  }
435  else
436  {
437  // elementwise swap
438  XsSize i;
439  assert(aArray->m_size == bArray->m_size);
440  for (i = 0; i < aArray->m_size; ++i)
441  aArray->m_descriptor->itemSwap(elemAtX(aArray->m_data, i, aArray), elemAtX(bArray->m_data, i, bArray));
442  }
443 }
444 
448 void XsArray_erase(void* thisPtr, XsSize index, XsSize count)
449 {
450  XsSize i, newCount;
451  XsArray* thisArray = (XsArray*) thisPtr;
452 
453  if (count == 0 || index >= thisArray->m_size)
454  return;
455 
456  if (count + index > thisArray->m_size)
457  count = thisArray->m_size - index;
458 
459  newCount = thisArray->m_size - count;
460 
461  // move items into the gap by swapping
462  for (i = index; i < newCount; ++i)
463  thisArray->m_descriptor->itemSwap(elemAt(thisArray->m_data, i), elemAt(thisArray->m_data, i + count));
464 
465  *((XsSize*) &thisArray->m_size) = newCount;
466 }
467 
479 int XsArray_compare(void const* a, void const* b)
480 {
481  XsSize i;
482  XsArray const* aArray = (XsArray const*) a;
483  XsArray const* bArray = (XsArray const*) b;
484 
485  if (aArray == bArray)
486  return 0;
487 
488  if (aArray->m_size != bArray->m_size)
489  return (aArray->m_size < bArray->m_size) ? -1 : 1;
490 
491  assert(aArray->m_descriptor->itemCompare);
492  // we could theoretically only check the sizes and ignore the element-comparison in thisArray case
493  for (i = 0; i < aArray->m_size; ++i) // loop over all elements of the lists
494  {
495  int r = aArray->m_descriptor->itemCompare(elemAtX(aArray->m_data, i, aArray), elemAtX(bArray->m_data, i, bArray));
496  if (r)
497  return r;
498  }
499  return 0;
500 }
501 
514 int XsArray_comparePredicate(void const* a, void const* b, XsArrayItemCompareFunc predicate)
515 {
516  XsSize i;
517  XsArray const* aArray = (XsArray const*) a;
518  XsArray const* bArray = (XsArray const*) b;
519 
520  if (aArray == bArray)
521  return 0;
522 
523  if (aArray->m_size != bArray->m_size)
524  return (aArray->m_size < bArray->m_size) ? -1 : 1;
525 
526  assert(predicate);
527  // we could theoretically only check the sizes and ignore the element-comparison in thisArray case
528  for (i = 0; i < aArray->m_size; ++i) // loop over all elements of the lists
529  {
530  int r = predicate(elemAtX(aArray->m_data, i, aArray), elemAtX(bArray->m_data, i, bArray));
531  if (r)
532  return r;
533  }
534  return 0;
535 }
536 
549 int XsArray_compareSet(void const* a, void const* b)
550 {
551  XsSize n, m;
552  XsArray const* aArray = (XsArray const*) a;
553  XsArray const* bArray = (XsArray const*) b;
554 
555  if (aArray == bArray)
556  return 0;
557 
558  if (aArray->m_size != bArray->m_size)
559  return (aArray->m_size < bArray->m_size) ? -1 : 1;
560 
561  for (n = 0; n < aArray->m_size; ++n) // loop over all elements of list aArray
562  {
563  int found = 0;
564  for (m = 0; m < bArray->m_size; ++m) // loop over all elements of list bArray
565  {
566  if (aArray->m_descriptor->itemCompare(elemAtX(aArray->m_data, n, aArray), elemAtX(bArray->m_data, m, bArray)) == 0)
567  {
568  found = 1;
569  break;
570  }
571  }
572  if (!found)
573  return -1;
574  }
575  return 0;
576 }
577 
585 ptrdiff_t XsArray_find(void const* thisPtr, void const* needle)
586 {
587  XsSize i;
588  XsArray const* thisArray = (XsArray const*) thisPtr;
589 
590  assert(thisArray->m_descriptor->itemCompare);
591  // we could theoretically only check the sizes and ignore the element-comparison in thisArray case
592  for (i = 0; i < thisArray->m_size; ++i) // loop over all elements of the lists
593  if (!thisArray->m_descriptor->itemCompare(elemAt(thisArray->m_data, i), needle))
594  return (ptrdiff_t) i;
595  return -1;
596 }
597 
607 ptrdiff_t XsArray_findPredicate(void const* thisPtr, void const* needle, XsArrayItemCompareFunc predicate)
608 {
609  XsSize i;
610  XsArray const* thisArray = (XsArray const*) thisPtr;
611 
612  assert(predicate);
613  // we could theoretically only check the sizes and ignore the element-comparison in thisArray case
614  for (i = 0; i < thisArray->m_size; ++i) // loop over all elements of the lists
615  if (!predicate(elemAt(thisArray->m_data, i), needle))
616  return (ptrdiff_t) i;
617  return -1;
618 }
619 
625 void const* XsArray_at(void const* thisPtr, XsSize index)
626 {
627  XsArray const* thisArray = (XsArray const*) thisPtr;
628  if (index >= thisArray->m_size)
629  return 0;
630  return elemAt(thisArray->m_data, index);
631 }
632 
638 void* XsArray_atIndex(void* thisPtr, XsSize index)
639 {
640  XsArray* thisArray = (XsArray*) thisPtr;
641  if (index >= thisArray->m_size)
642  return 0;
643  return elemAt(thisArray->m_data, index);
644 }
645 
649 void XsArray_removeDuplicates(void* thisPtr)
650 {
651  XsSize i, j;
652  XsArray* thisArray = (XsArray*) thisPtr;
653  if (thisArray->m_size > 1)
654  {
655  for (i = 0; i < thisArray->m_size - 1; ++i)
656  {
657  for (j = thisArray->m_size - 1; j > i; --j)
658  {
659  if (!thisArray->m_descriptor->itemCompare(elemAt(thisArray->m_data, i), elemAt(thisArray->m_data, j)))
660  XsArray_erase(thisPtr, j, 1);
661  }
662  }
663  }
664 }
665 
670 void XsArray_removeDuplicatesPredicate(void* thisPtr, XsArrayItemCompareFunc predicate)
671 {
672  XsSize i, j;
673  XsArray* thisArray = (XsArray*) thisPtr;
674  if (thisArray->m_size > 1)
675  {
676  for (i = 0; i < thisArray->m_size - 1; ++i)
677  {
678  for (j = thisArray->m_size - 1; j > i; --j)
679  {
680  if (!predicate(elemAt(thisArray->m_data, i), elemAt(thisArray->m_data, j)))
681  XsArray_erase(thisPtr, j, 1);
682  }
683  }
684  }
685 }
686 
693 int XsArray_empty(void const* thisPtr)
694 {
695  XsArray const* thisArray = (XsArray const*) thisPtr;
696  return (thisArray->m_size == 0) || (thisArray->m_data == 0) || (thisArray->m_flags & XSDF_Empty);
697 }
698 
707 void XsArray_rawCopy(void* to, void const* from, XsSize count, XsSize iSize)
708 {
709  memcpy(to, from, count * iSize);
710 }
711 
716 void XsArray_sort(void* thisPtr)
717 {
718  XsArray* thisArray = (XsArray*) thisPtr;
719  qsort(thisArray->m_data, thisArray->m_size, thisArray->m_descriptor->itemSize, thisArray->m_descriptor->itemCompare);
720 }
721 
726 void XsArray_reverse(void* thisPtr)
727 {
728  XsSize i, half;
729  XsArray* thisArray = (XsArray*) thisPtr;
730  half = thisArray->m_size >> 1;
731  for (i = 0; i < half; ++i)
732  thisArray->m_descriptor->itemSwap(elemAt(thisArray->m_data, i), elemAt(thisArray->m_data, (thisArray->m_size - 1) - i));
733 }
734 
XsArrayDescriptor
This object describes how to treat the data in an array.
Definition: xsarray.h:103
XsArray::XsArray_construct
void XsArray_construct(void *thisPtr, XsArrayDescriptor const *const descriptor, XsSize count, void const *src)
Initializes the XsArray with space for count items and copies them from src.
Definition: xsarray.c:102
XsArray::XsArray_comparePredicate
int XsArray_comparePredicate(void const *a, void const *b, XsArrayItemCompareFunc predicate)
Returns non-zero if the lists are different, 0 if they're equal.
Definition: xsarray.c:514
XsArray::XsArray_rawCopy
void XsArray_rawCopy(void *to, void const *from, XsSize count, XsSize iSize)
Copies items optimized in a direct way.
Definition: xsarray.c:707
XsArray::XsArray_removeDuplicates
void XsArray_removeDuplicates(void *thisPtr)
Removes duplicate entries from the array, keeping only the first instance of each value.
Definition: xsarray.c:649
XsArray::XsArray_compare
int XsArray_compare(void const *a, void const *b)
Returns non-zero if the lists are different, 0 if they're equal.
Definition: xsarray.c:479
XsArray::XsArray_compareSet
int XsArray_compareSet(void const *a, void const *b)
Returns -1 if a is smaller in some way than b, 1 if it is larger in some way and 0 if both lists are ...
Definition: xsarray.c:549
XsArray::XsArray_reverse
void XsArray_reverse(void *thisPtr)
Reverses the contents of the array by repeatedly using the itemSwap func in the XsArrayDescriptor.
Definition: xsarray.c:726
s
XmlRpcServer s
XsArray::XsArray_destruct
void XsArray_destruct(void *thisPtr)
Clears and frees memory allocated by the XsArray.
Definition: xsarray.c:157
XsArray::XsArray_append
void XsArray_append(void *thisPtr, void const *other)
Appends the other list to thisArray list.
Definition: xsarray.c:319
XsArray
Provides generic storage for data in an array and manipulation operations on that data.
Definition: xsarray.h:159
XsArray::XsArray_copy
void XsArray_copy(void *thisPtr, void const *src)
Copy the contents of src to thisArray.
Definition: xsarray.c:305
XSDF_FixedSize
@ XSDF_FixedSize
The contained data points to a fixed-size buffer, this allows creation of dynamic objects on the stac...
Definition: xstypedefs.h:111
XsArray::XsArray_sort
void XsArray_sort(void *thisPtr)
Sorts the array using the itemCompare func in the XsArrayDescriptor.
Definition: xsarray.c:716
XsArray::XsArray_erase
void XsArray_erase(void *thisPtr, XsSize index, XsSize count)
Removes a count items from the list starting at index.
Definition: xsarray.c:448
XsArray_incFreeCount
static int XsArray_incFreeCount(void)
Definition: xsdebugcounters.h:157
xsdebugcounters.h
XsArray::XsArray_copyConstruct
void XsArray_copyConstruct(void *thisPtr, void const *src)
Initializes the XsArray with a copy of src.
Definition: xsarray.c:144
XsArray::XsArray_atIndex
void * XsArray_atIndex(void *thisPtr, XsSize index)
Returns a pointer to the item at the supplied index or a null pointer if it is out of bounds.
Definition: xsarray.c:638
XsArray::XsArray_swap
void XsArray_swap(void *a, void *b)
Swap the contents of a with those of b.
Definition: xsarray.c:408
d
d
XsArray::XsArray_removeDuplicatesPredicate
void XsArray_removeDuplicatesPredicate(void *thisPtr, XsArrayItemCompareFunc predicate)
Removes duplicate entries from the array, keeping only the first instance of each value.
Definition: xsarray.c:670
XsSize
size_t XsSize
XsSize must be unsigned number!
Definition: xstypedefs.h:74
XsArray::XsArray_assign
void XsArray_assign(void *thisPtr, XsSize count, void const *src)
Reinitializes the XsArray with space for count items and copies them from src.
Definition: xsarray.c:186
xsarray.h
XsArray::XsArray_resize
void XsArray_resize(void *thisPtr, XsSize count)
Resizes the existing list to count items.
Definition: xsarray.c:227
XsArray::XsArray_insert
void XsArray_insert(void *thisPtr, XsSize index, XsSize count, void const *src)
Insert count items from src at index in the array.
Definition: xsarray.c:372
XSDF_Empty
@ XSDF_Empty
The object contains undefined data / should be considered empty. Usually only relevant when XSDF_Fixe...
Definition: xstypedefs.h:112
XsArray::XsArray_reserve
void XsArray_reserve(void *thisPtr, XsSize count)
Reserves space for count items.
Definition: xsarray.c:256
XsArray::XsArray_at
void const * XsArray_at(void const *thisPtr, XsSize index)
Returns a pointer to the item at the supplied index or a null pointer if it is out of bounds.
Definition: xsarray.c:625
XSDF_Managed
@ XSDF_Managed
The contained data should be managed (freed) by the object, when false, the object assumes the memory...
Definition: xstypedefs.h:110
XsArray_incAllocCount
static int XsArray_incAllocCount(void)
Definition: xsdebugcounters.h:153
XsArray::XsArray_empty
int XsArray_empty(void const *thisPtr)
Returns whether the array is empty.
Definition: xsarray.c:693
XsArray::XsArray_find
ptrdiff_t XsArray_find(void const *thisPtr, void const *needle)
Returns the index of needle in the list or -1 if it wasn't found.
Definition: xsarray.c:585
XsArray::XsArray_findPredicate
ptrdiff_t XsArray_findPredicate(void const *thisPtr, void const *needle, XsArrayItemCompareFunc predicate)
Returns the index of needle in the list or -1 if it wasn't found.
Definition: xsarray.c:607


xsens_mti_driver
Author(s):
autogenerated on Sun Sep 3 2023 02:43:20