OCC Main Page | FoundationClasses | Toolkits | Packages | Class Hierarchy | Data Structures | File List | Data Fields | Globals

FoundationClasses
TKernel
NCollection


NCollection_UBTreeFiller< TheObjType, TheBndType > Class Template Reference

#include <NCollection_UBTreeFiller.hxx>


Public Types

typedef NCollection_UBTree<
TheObjType, TheBndType > 
UBTree
 UBTree algorithm.
typedef TYPENAME UBTree::TreeNode UBTreeNode

Public Member Functions

 NCollection_UBTreeFiller (UBTree &theTree, const Standard_Boolean isFullRandom=Standard_True)
void Add (const TheObjType &theObj, const TheBndType &theBnd)
 Adds a pair (theObj, theBnd) to my sequence.
Standard_EXPORT Standard_Integer Fill ()
Standard_EXPORT Standard_Integer CheckTree (Standard_OStream &theStream)
 ~NCollection_UBTreeFiller ()

Static Private Member Functions

static Standard_Real checkNode (const UBTreeNode &theNode, const Standard_Integer theLength, Standard_Integer &theNumber)

Private Attributes

UBTreemyTree
NCollection_Vector< ObjBndmySeqPtr
int mySeed
 seed for rand
Standard_Boolean myIsFullRandom

Data Structures

struct  ObjBnd
 Structure of pair (object, bnd box). More...


Detailed Description

template<class TheObjType, class TheBndType>
class NCollection_UBTreeFiller< TheObjType, TheBndType >

This class is used to fill an UBTree in a random order. The quality of a tree is much better (from the point of view of the search time) if objects are added to it in a random order to avoid adding a chain of neerby objects one following each other.

This class collects objects to be added, and then add them to the tree in a random order.


Member Typedef Documentation

template<class TheObjType, class TheBndType>
typedef NCollection_UBTree<TheObjType, TheBndType> NCollection_UBTreeFiller< TheObjType, TheBndType >::UBTree
 

template<class TheObjType, class TheBndType>
typedef TYPENAME UBTree::TreeNode NCollection_UBTreeFiller< TheObjType, TheBndType >::UBTreeNode
 


Constructor & Destructor Documentation

template<class TheObjType, class TheBndType>
NCollection_UBTreeFiller< TheObjType, TheBndType >::NCollection_UBTreeFiller UBTree theTree,
const Standard_Boolean  isFullRandom = Standard_True
[inline]
 

Constructor.

Parameters:
theTree Tree instance that is to be filled.
isFullRandom Takes effect when the number of items is large (order of 50,000). When it is True, the code uses the maximal randomization allowing a better balanced tree. If False, the randomization/tree balance are worse but the tree filling is faster due to better utilisation of CPU L1/L2 cache.

template<class TheObjType, class TheBndType>
NCollection_UBTreeFiller< TheObjType, TheBndType >::~NCollection_UBTreeFiller  )  [inline]
 

Destructor. Fills the tree with accumulated items if they have not been passed by a previous call of method Fill().


Member Function Documentation

template<class TheObjType, class TheBndType>
void NCollection_UBTreeFiller< TheObjType, TheBndType >::Add const TheObjType &  theObj,
const TheBndType &  theBnd
[inline]
 

template<class TheObjType, class TheBndType>
static Standard_Real NCollection_UBTreeFiller< TheObjType, TheBndType >::checkNode const UBTreeNode theNode,
const Standard_Integer  theLength,
Standard_Integer theNumber
[static, private]
 

template<class TheObjType, class TheBndType>
Standard_Integer NCollection_UBTreeFiller< TheObjType, TheBndType >::CheckTree Standard_OStream theStream  ) 
 

Check the filled tree for the total number of items and the balance outputting these results to ostream.

Returns:
the tree size (the same value is returned by method Fill()).

template<class TheObjType, class TheBndType>
Standard_Integer NCollection_UBTreeFiller< TheObjType, TheBndType >::Fill  ) 
 

Fills the tree with the objects from my sequence. This method clears the internal buffer of added items making sure that no item would be added twice.

Returns:
the number of objects added to the tree.


Field Documentation

template<class TheObjType, class TheBndType>
Standard_Boolean NCollection_UBTreeFiller< TheObjType, TheBndType >::myIsFullRandom [private]
 

template<class TheObjType, class TheBndType>
int NCollection_UBTreeFiller< TheObjType, TheBndType >::mySeed [private]
 

template<class TheObjType, class TheBndType>
NCollection_Vector<ObjBnd> NCollection_UBTreeFiller< TheObjType, TheBndType >::mySeqPtr [private]
 

template<class TheObjType, class TheBndType>
UBTree& NCollection_UBTreeFiller< TheObjType, TheBndType >::myTree [private]
 


The documentation for this class was generated from the following file:
Generated on Mon Aug 25 13:13:02 2008 for OpenCASCADE by  doxygen 1.4.1