Blender V5.3
blender::DisjointSet< T > Class Template Reference

#include <BLI_disjoint_set.hh>

Public Member Functions

 DisjointSet (const int64_t size)
T join (const T x, const T y)
bool in_same_set (const T x, const T y)
T find_root (const T x)
T find_root (const T x) const

Detailed Description

template<typename T = int64_t>
class blender::DisjointSet< T >

Definition at line 18 of file BLI_disjoint_set.hh.

Constructor & Destructor Documentation

◆ DisjointSet()

template<typename T = int64_t>
blender::DisjointSet< T >::DisjointSet ( const int64_t size)
inline

Create a new disjoint set with the given size. Initially, every element is in a separate set.

Definition at line 27 of file BLI_disjoint_set.hh.

References blender::BLI_assert(), blender::IndexRange::IndexRange(), and T.

Member Function Documentation

◆ find_root() [1/2]

template<typename T = int64_t>
T blender::DisjointSet< T >::find_root ( const T x)
inline

Find the element that represents the set containing x currently.

Definition at line 75 of file BLI_disjoint_set.hh.

References T, and blender::x.

Referenced by in_same_set(), join(), blender::ntree_update_reroute_nodes(), and blender::tests::TEST().

◆ find_root() [2/2]

template<typename T = int64_t>
T blender::DisjointSet< T >::find_root ( const T x) const
inline

Same as above but intended to be threadsafe. Better to use even if this is expected to be not an issue.

Definition at line 98 of file BLI_disjoint_set.hh.

References T, and blender::x.

◆ in_same_set()

template<typename T = int64_t>
bool blender::DisjointSet< T >::in_same_set ( const T x,
const T y )
inline

Return true when x and y are in the same set.

Definition at line 65 of file BLI_disjoint_set.hh.

References find_root(), T, blender::x, and y.

Referenced by blender::tests::TEST().

◆ join()

template<typename T = int64_t>
T blender::DisjointSet< T >::join ( const T x,
const T y )
inline

Join the sets containing elements x and y. Nothing happens when they have been in the same set before. Shared root is returned.

Definition at line 39 of file BLI_disjoint_set.hh.

References find_root(), T, blender::x, and y.

Referenced by blender::ntree_update_reroute_nodes(), and blender::tests::TEST().


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