PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches
lwunionfind.h
Go to the documentation of this file.
1/**********************************************************************
2 *
3 * PostGIS - Spatial Types for PostgreSQL
4 * http://postgis.net
5 *
6 * PostGIS is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PostGIS is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PostGIS. If not, see <http://www.gnu.org/licenses/>.
18 *
19 **********************************************************************
20 *
21 * Copyright 2015 Daniel Baston <dbaston@gmail.com>
22 *
23 **********************************************************************/
24
25
26#ifndef _LWUNIONFIND
27#define _LWUNIONFIND 1
28
29#include "liblwgeom.h"
30
31typedef struct
32{
33 uint32_t* clusters;
34 uint32_t* cluster_sizes;
35 uint32_t num_clusters;
36 uint32_t N;
37} UNIONFIND;
38
39/* Allocate a UNIONFIND structure of capacity N */
40UNIONFIND* UF_create(uint32_t N);
41
42/* Release memory associated with UNIONFIND structure */
43void UF_destroy(UNIONFIND* uf);
44
45/* Identify the cluster id associated with specified component id */
46uint32_t UF_find(UNIONFIND* uf, uint32_t i);
47
48/* Get the size of the cluster associated with the specified component id */
49uint32_t UF_size(UNIONFIND* uf, uint32_t i);
50
51/* Merge the clusters that contain the two specified component ids */
52void UF_union(UNIONFIND* uf, uint32_t i, uint32_t j);
53
54/* Return an array of component ids, where components that are in the
55 * same cluster are contiguous in the array */
56uint32_t* UF_ordered_by_cluster(UNIONFIND* uf);
57
58/* Replace the cluster ids in a UNIONFIND with sequential ids starting at one.
59 * If is_in_cluster array is provided, it will be used to skip any indexes
60 * that are not in a cluster.
61 * */
62uint32_t* UF_get_collapsed_cluster_ids(UNIONFIND* uf, const char* is_in_cluster);
63
64#endif
This library is the generic geometry handling section of PostGIS.
void UF_destroy(UNIONFIND *uf)
Definition lwunionfind.c:54
uint32_t UF_find(UNIONFIND *uf, uint32_t i)
Definition lwunionfind.c:62
uint32_t UF_size(UNIONFIND *uf, uint32_t i)
Definition lwunionfind.c:79
uint32_t * UF_ordered_by_cluster(UNIONFIND *uf)
UNIONFIND * UF_create(uint32_t N)
Definition lwunionfind.c:35
uint32_t * UF_get_collapsed_cluster_ids(UNIONFIND *uf, const char *is_in_cluster)
void UF_union(UNIONFIND *uf, uint32_t i, uint32_t j)
Definition lwunionfind.c:85
uint32_t N
Definition lwunionfind.h:36
uint32_t * cluster_sizes
Definition lwunionfind.h:34
uint32_t * clusters
Definition lwunionfind.h:33
uint32_t num_clusters
Definition lwunionfind.h:35