HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_Classifier Class Reference

#include <UT_Classifier.h>

Public Member Functions

 UT_Classifier (bool track_class_sizes=false)
 
 UT_Classifier (const UT_Classifier &other)
 
 ~UT_Classifier ()=default
 
UT_Classifieroperator= (const UT_Classifier &other)
 
SYS_FORCE_INLINE exint makeClass ()
 
SYS_FORCE_INLINE exint makeClass (exint num_classes)
 
SYS_FORCE_INLINE void unionClasses (exint a, exint b)
 
SYS_FORCE_INLINE exint classRoot (exint elem) const
 
SYS_FORCE_INLINE bool areInSameClass (exint a, exint b) const
 
exint numClasses () const
 Return number of distinct classes. More...
 
exint size () const
 Return the total number of elements in all classes. More...
 
exint entries () const
 
SYS_FORCE_INLINE exint classIndex (exint elem) const
 
SYS_FORCE_INLINE exint classSize (exint elem) const
 
void getAllClassIndices (UT_IntArray &out_array)
 Copy the whole index array. More...
 
void consolidate (bool keep_size=false, bool keep_index=false)
 
void reset (exint new_size=-1)
 
void buildIndex (bool root_independent=false, exint min_class_size=1)
 
exint numIndexedClasses () const
 

Detailed Description

Definition at line 75 of file UT_Classifier.h.

Constructor & Destructor Documentation

UT_Classifier::UT_Classifier ( bool  track_class_sizes = false)
inline

Definition at line 78 of file UT_Classifier.h.

UT_Classifier::UT_Classifier ( const UT_Classifier other)
inline

Definition at line 81 of file UT_Classifier.h.

UT_Classifier::~UT_Classifier ( )
default

Member Function Documentation

SYS_FORCE_INLINE bool UT_Classifier::areInSameClass ( exint  a,
exint  b 
) const
inline

Definition at line 109 of file UT_Classifier.h.

void UT_Classifier::buildIndex ( bool  root_independent = false,
exint  min_class_size = 1 
)

Explicit request to build the index, instead of implicitly triggering it by calling classIndex(). If root_independent is true, the created index of each class will be the relative rank of its smallest element compared to other classes. Otherwise, it will be the relative rank of the class root (default) which is the case if the index is build implicitly. If min_class_size is set to a number larger than 1, only classes with min_class_size elements or larger are assigned a usual index and other classes are assigned -1.

SYS_FORCE_INLINE exint UT_Classifier::classIndex ( exint  elem) const
inline

Returns an ordinal number between 0 and number of classes - 1. buildIndex() must be called explicitly before calling classIndex(). Calling makeClasses() or unionClasses() invalidate the index and

Definition at line 124 of file UT_Classifier.h.

exint UT_Classifier::classRoot ( exint  elem) const

Look up the ticket number for the root element of the part of the parameter element

Definition at line 342 of file UT_Classifier.h.

SYS_FORCE_INLINE exint UT_Classifier::classSize ( exint  elem) const
inline

Definition at line 131 of file UT_Classifier.h.

void UT_Classifier::consolidate ( bool  keep_size = false,
bool  keep_index = false 
)

Free up all unnecessary information except for class roots. makeClass and unionClasses operation are ignored on a consolidated classifier. class size and index information are also expunged (unless keep_size or keep_index are respectively set to true) and methods classIndex() and classSize() return -1 on all input. Of course classRoot() very much works as usual after consolidation! Calling reset() revives the object from the state of consolidation but naturally resets all the classes into singletons.

exint UT_Classifier::entries ( ) const
inline

Definition at line 117 of file UT_Classifier.h.

void UT_Classifier::getAllClassIndices ( UT_IntArray out_array)

Copy the whole index array.

exint UT_Classifier::makeClass ( )

create one or more singleton classes which get consecutive ticket numbers returns the ticket number of that last class created

Definition at line 280 of file UT_Classifier.h.

exint UT_Classifier::makeClass ( exint  num_classes)

Definition at line 290 of file UT_Classifier.h.

exint UT_Classifier::numClasses ( ) const
inline

Return number of distinct classes.

Definition at line 113 of file UT_Classifier.h.

exint UT_Classifier::numIndexedClasses ( ) const
inline

Definition at line 169 of file UT_Classifier.h.

UT_Classifier & UT_Classifier::operator= ( const UT_Classifier other)
inline

Definition at line 366 of file UT_Classifier.h.

void UT_Classifier::reset ( exint  new_size = -1)

Reset all the elements to singleton classes. If new_size is non-negative the number of classes are changed to new_size with ticket numbers 0 to new_size - 1. Otherwise, all classes are made singletons again.

exint UT_Classifier::size ( void  ) const
inline

Return the total number of elements in all classes.

Definition at line 116 of file UT_Classifier.h.

void UT_Classifier::unionClasses ( exint  a,
exint  b 
)

merge the classes containing elements with tickets a and b into a single part

Definition at line 307 of file UT_Classifier.h.


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