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

#include <UT_Classifier.h>

Public Member Functions

 UT_Classifier (bool track_class_sizes=false)
 ~UT_Classifier ()=default
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, bool root_independent=false)
SYS_FORCE_INLINE exint classSize (exint elem)
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)

Definition at line 78 of file UT_Classifier.h.

UT_Classifier::~UT_Classifier ( )

Member Function Documentation

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

Definition at line 103 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_indepent is true, the created index of eac 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,
bool  root_independent = false 

Returns an ordinal number between 0 and number of classes - 1 creation of new classes or unification of distinct classes invalidate class indices. Each time the class indices are invalidated, the first call to classIndex takes linear time. All subsequent calls take constant time so long as the class indices remain valid. The root_independent parameter is passed to buildIndex() if the index has not been previously built needs to be rebuilt. See the comments above that method for explanation.

Definition at line 123 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 344 of file UT_Classifier.h.

SYS_FORCE_INLINE exint UT_Classifier::classSize ( exint  elem)

Definition at line 133 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 ( void  ) const

Definition at line 111 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 282 of file UT_Classifier.h.

exint UT_Classifier::makeClass ( exint  num_classes)

Definition at line 292 of file UT_Classifier.h.

exint UT_Classifier::numClasses ( ) const

Return number of distinct classes.

Definition at line 107 of file UT_Classifier.h.

exint UT_Classifier::numIndexedClasses ( ) const

Definition at line 171 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

Return the total number of elements in all classes.

Definition at line 110 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 309 of file UT_Classifier.h.

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