MCPcopy Create free account
hub / github.com/apache/cloudberry / qunique

Function qunique

src/include/lib/qunique.h:20–39  ·  view source on GitHub ↗

* Remove duplicates from a pre-sorted array, according to a user-supplied * comparator. Usually the array should have been sorted with qsort() using * the same arguments. Return the new size. */

Source from the content-addressed store, hash-verified

18 * the same arguments. Return the new size.
19 */
20static inline size_t
21qunique(void *array, size_t elements, size_t width,
22 int (*compare) (const void *, const void *))
23{
24 char *bytes = (char *) array;
25 size_t i,
26 j;
27
28 if (elements <= 1)
29 return elements;
30
31 for (i = 1, j = 0; i < elements; ++i)
32 {
33 if (compare(bytes + i * width, bytes + j * width) != 0 &&
34 ++j != i)
35 memcpy(bytes + j * width, bytes + i * width, width);
36 }
37
38 return j + 1;
39}
40
41/*
42 * Like qunique(), but takes a comparator with an extra user data argument

Callers 12

generate_trgmFunction · 0.85
generate_wildcard_trgmFunction · 0.85
InitCatalogCacheFunction · 0.85
tsq_mcontainsFunction · 0.85
gtsvector_compressFunction · 0.85
aclmembersFunction · 0.85
sort_snapshotFunction · 0.85
array_to_tsvectorFunction · 0.85
checkcondition_strFunction · 0.85
_bt_deadblocksFunction · 0.85
TidListEvalFunction · 0.85

Calls 1

compareFunction · 0.50

Tested by

no test coverage detected