GEOS 3.14.0dev
Public Member Functions | List of all members
geos::operation::cluster::UnionFind Class Reference

#include <UnionFind.h>

Public Member Functions

 UnionFind (size_t n)
 
bool same (size_t i, size_t j)
 
bool different (size_t i, size_t j)
 
size_t find (size_t i)
 
void join (size_t i, size_t j)
 
size_t getNumClusters () const
 
template<typename T >
void sortByCluster (T begin, T end)
 
Clusters getClusters ()
 
Clusters getClusters (std::vector< size_t > elems)
 

Detailed Description

UnionFind provides an implementation of a disjoint set data structure that is useful in clustering. Elements to be clustered are referred to according to a numeric index.

Constructor & Destructor Documentation

◆ UnionFind()

geos::operation::cluster::UnionFind::UnionFind ( size_t  n)
inlineexplicit

Create a UnionFind object

Parameters
nthe number of elements to be clustered (fixed size)

Member Function Documentation

◆ find()

size_t geos::operation::cluster::UnionFind::find ( size_t  i)
inline

Return the ID of the cluster associated with an item

Parameters
iindex of the item to lookup
Returns
a numeric cluster ID

◆ getClusters() [1/2]

Clusters geos::operation::cluster::UnionFind::getClusters ( )

Return the clusters associated with all elements

Returns
an object that allows iteration over the elements of each cluster

◆ getClusters() [2/2]

Clusters geos::operation::cluster::UnionFind::getClusters ( std::vector< size_t >  elems)

Return the clusters associated with the given elements

Parameters
elemsa vector of element ids
Returns
an object that allows iteration over the elements of each cluster

◆ join()

void geos::operation::cluster::UnionFind::join ( size_t  i,
size_t  j 
)
inline

Merge the clusters associated with two items

Parameters
iID of an item associated with the first cluster
jID of an item associated with the second cluster

The documentation for this class was generated from the following file: