PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
qunique.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

static size_t qunique (void *array, size_t elements, size_t width, int(*compare)(const void *, const void *))
 
static size_t qunique_arg (void *array, size_t elements, size_t width, int(*compare)(const void *, const void *, void *), void *arg)
 

Function Documentation

◆ qunique()

static size_t qunique ( void *  array,
size_t  elements,
size_t  width,
int(*)(const void *, const void *)  compare 
)
inlinestatic

Definition at line 21 of file qunique.h.

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}
static int compare(const void *arg1, const void *arg2)
Definition: geqo_pool.c:145
int j
Definition: isn.c:78
int i
Definition: isn.c:77

References compare(), i, and j.

Referenced by _bt_deadblocks(), aclmembers(), AddRoleMems(), array_to_tsvector(), checkcondition_str(), generate_trgm(), generate_wildcard_trgm(), gtsvector_compress(), InitCatalogCache(), sort_snapshot(), TidListEval(), tsq_mcontains(), and tsvector_delete_by_indices().

◆ qunique_arg()

static size_t qunique_arg ( void *  array,
size_t  elements,
size_t  width,
int(*)(const void *, const void *, void *)  compare,
void *  arg 
)
inlinestatic

Definition at line 46 of file qunique.h.

49{
50 char *bytes = (char *) array;
51 size_t i,
52 j;
53
54 if (elements <= 1)
55 return elements;
56
57 for (i = 1, j = 0; i < elements; ++i)
58 {
59 if (compare(bytes + i * width, bytes + j * width, arg) != 0 &&
60 ++j != i)
61 memcpy(bytes + j * width, bytes + i * width, width);
62 }
63
64 return j + 1;
65}
void * arg

References arg, compare(), i, and j.

Referenced by _bt_sort_array_elements(), and _int_unique().