64 #ifndef __UT_Classifier__
65 #define __UT_Classifier__
71 #define PARENT_MASK 0x00ffffffffffffff
72 #define RANK_MASK 0xff00000000000000
73 #define RANK_BUMP 0x0100000000000000
79 myTrackSizes(track_class_sizes) { }
110 {
return classRoot(a) == classRoot(b); }
127 return myIndex(elem);
134 return mySize.size() > 0 ? mySize(classRoot(elem)) : -1;
148 void consolidate(
bool keep_size =
false,
149 bool keep_index =
false);
166 void buildIndex(
bool root_independent =
false,
167 exint min_class_size = 1);
170 {
return myNumIndexedClasses; }
185 { myElems(i) = ((myElems(i) &
RANK_MASK) | p); }
199 exint myNumClasses = 0;
200 exint myNumIndexedClasses = 0;
205 template <
typename T>
209 myClasses(track_class_sizes) { }
236 exint numClasses()
const
241 {
return myClasses.
size(); }
244 { myClasses.
reset(); }
257 {
return myRef(elem); }
261 T &getClassRootRef(
exint elem)
267 void consolidate(
bool keep_size =
false,
268 bool keep_index =
false)
282 auto s = myElems.
size();
292 auto s = myElems.
size();
295 for (
exint i =
s, ie = myElems.
size(); i < ie; i++)
301 myNumClasses += num_classes;
302 return myElems.
size() - 1;
315 auto arootrank = rank(aroot);
316 auto brootrank = rank(broot);
318 if (arootrank < brootrank)
320 parent(aroot, broot);
322 mySize(broot) += mySize(aroot);
324 else if (brootrank < arootrank)
326 parent(broot, aroot);
328 mySize(aroot) += mySize(broot);
332 parent(broot, aroot);
335 mySize(aroot) += mySize(broot);
368 myElems = other.myElems;
369 mySize = other.mySize;
370 myIndex = other.myIndex;
372 myTrackSizes = other.myTrackSizes;
373 myNumClasses = other.myNumClasses;
374 myNumIndexedClasses = other.myNumIndexedClasses;
SYS_FORCE_INLINE exint makeClass()
UT_Classifier & operator=(const UT_Classifier &other)
SYS_FORCE_INLINE void unionClasses(exint a, exint b)
SYS_FORCE_INLINE bool areInSameClass(exint a, exint b) const
GLboolean GLboolean GLboolean GLboolean a
exint size() const
Return the total number of elements in all classes.
SYS_FORCE_INLINE exint classIndex(exint elem) const
UT_Classifier(bool track_class_sizes=false)
void reset(exint new_size=-1)
exint numIndexedClasses() const
void appendMultiple(const T &t, exint count)
void consolidate(bool keep_size=false, bool keep_index=false)
GLboolean GLboolean GLboolean b
UT_Classifier(const UT_Classifier &other)
exint numClasses() const
Return number of distinct classes.
LeafData & operator=(const LeafData &)=delete
SYS_FORCE_INLINE exint classSize(exint elem) const
SYS_FORCE_INLINE exint classRoot(exint elem) const