Gromacs  2020.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions
gmx::MappedUnionFinder Class Reference

#include <gromacs/trajectoryanalysis/modules/unionfind.h>

Description

Extension of UnionFind that supports non-consecutive integer indices as items.

Sometimes, it is more convenient to operate on a set of integers that do not start at zero and are not consecutive as UnionFind expects. This class implements a mapping on top of UnionFind such that this is possible.

The current implementation assumes that the indices are bounded between zero and some reasonably small integer, i.e., the memory usage depends on the largest index number, not just on the number of items.

Public Member Functions

void initWithGroupIndices (ArrayRef< const int > indices)
 Initializes the finder with indices. More...
 
int representativeValue (int group)
 Returns a reprensetative value for an item that is unique for each set. More...
 
void mergeGroups (int group1, int group2)
 Merges sets that contain two given items. More...
 
std::vector< int > allSizes ()
 Returns the sizes of all sets (in arbitrary order). More...
 

Member Function Documentation

std::vector<int> gmx::MappedUnionFinder::allSizes ( )
inline

Returns the sizes of all sets (in arbitrary order).

If there were multiple identical indices passed to initWithGroupIndices(), these are only counted as one when computing the sizes.

void gmx::MappedUnionFinder::initWithGroupIndices ( ArrayRef< const int >  indices)
inline

Initializes the finder with indices.

The size of indices sets the number of input items, and each unique value in indices maps to a single internal item. If multiple indices are the same, then these items are considered equivalent.

void gmx::MappedUnionFinder::mergeGroups ( int  group1,
int  group2 
)
inline

Merges sets that contain two given items.

If the items are already in the same set, nothing happens. Each input value should be one of the values that were passed in as an index to initWithGroupIndices().

int gmx::MappedUnionFinder::representativeValue ( int  group)
inline

Returns a reprensetative value for an item that is unique for each set.

group should be one of the values that were passed in as an index to initWithGroupIndices(). The return value is an internal index that has no simple relation to the input indices.


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