PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ test_unionfind_ordered_by_cluster()

static void test_unionfind_ordered_by_cluster ( void  )
static

Definition at line 53 of file cu_unionfind.c.

54 {
55  uint32_t final_clusters[] = { 0, 2, 2, 2, 4, 5, 6, 0, 0, 2 };
56  uint32_t final_sizes[] = { 3, 0, 4, 0, 1, 1, 1, 0, 0, 0 };
57 
58  /* Manually create UF at desired final state */
59  UNIONFIND uf =
60  {
61  .N = 10,
62  .num_clusters = 5,
63  .clusters = final_clusters,
64  .cluster_sizes = final_sizes
65  };
66 
67  uint32_t* ids_by_cluster = UF_ordered_by_cluster(&uf);
68 
69  char encountered_cluster[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
70 
71  uint32_t i;
72  for (i = 0; i < uf.N; i++)
73  {
74  uint32_t c = final_clusters[ids_by_cluster[i]];
75  if (!encountered_cluster[c])
76  {
77  encountered_cluster[c] = 1;
78  }
79  else
80  {
81  /* If we've seen an element of this cluster before, then the
82  * current cluster must be the same as the previous cluster. */
83  uint32_t c_prev = final_clusters[ids_by_cluster[i-1]];
84  CU_ASSERT_EQUAL(c, c_prev);
85  }
86  }
87  lwfree(ids_by_cluster);
88 }
void lwfree(void *mem)
Definition: lwutil.c:244
uint32_t * UF_ordered_by_cluster(UNIONFIND *uf)
Definition: lwunionfind.c:112
uint32_t N
Definition: lwunionfind.h:36
unsigned int uint32_t
Definition: uthash.h:78

References lwfree(), UNIONFIND::N, and UF_ordered_by_cluster().

Referenced by unionfind_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: