NL3D::COrderingTable< T > Class Template Reference

#include <ordering_table.h>


Detailed Description

template<class T>
class NL3D::COrderingTable< T >

Author:
Matthieu Besson

Nevrax France

Date:
2000

Definition at line 43 of file ordering_table.h.

Public Member Functions

void begin ()
 COrderingTable ()
T * get ()
uint32 getSize ()
void init (uint32 nNbEntries)
void insert (uint32 nEntryPos, T *pValue)
void next ()
void reset (uint maxElementToInsert)
 ~COrderingTable ()

Private Attributes

std::vector< CNode_Allocator
CNode_Array
CNode_CurAllocatedNode
uint32 _nNbElt
CNode_SelNode


Constructor & Destructor Documentation

template<class T>
NL3D::COrderingTable< T >::COrderingTable  ) 
 

Definition at line 130 of file ordering_table.h.

References NL3D::COrderingTable< T >::_Array, NL3D::COrderingTable< T >::_CurAllocatedNode, NL3D::COrderingTable< T >::_nNbElt, and NL3D::COrderingTable< T >::_SelNode.

00131 {
00132         _nNbElt = 0;
00133         _Array = NULL;
00134         _SelNode = NULL;
00135         _CurAllocatedNode= NULL;
00136 }

template<class T>
NL3D::COrderingTable< T >::~COrderingTable  ) 
 

Definition at line 139 of file ordering_table.h.

References NL3D::COrderingTable< T >::_Array.

00140 {
00141         if( _Array != NULL )
00142                 delete [] _Array;
00143 }


Member Function Documentation

template<class T>
void NL3D::COrderingTable< T >::begin  ) 
 

Traversing operations

OrderingTable<Face> ot; ot.begin(); while( ot.get() != NULL ) { Face *pF = ot.get(); // Do the treatment you want here ot.next(); }

Definition at line 205 of file ordering_table.h.

References NL3D::COrderingTable< T >::_Array, NL3D::COrderingTable< T >::_SelNode, NL3D::COrderingTable< T >::next(), and NL3D::COrderingTable< T >::CNode::val.

00206 {
00207         _SelNode = &_Array[0];
00208         if( _SelNode->val == NULL )
00209                 next();
00210 }

template<class T>
T * NL3D::COrderingTable< T >::get  ) 
 

Get the currently selected element.

Definition at line 213 of file ordering_table.h.

References NL3D::COrderingTable< T >::_SelNode, and NL3D::COrderingTable< T >::CNode::val.

00214 {
00215         if( _SelNode != NULL )
00216                 return _SelNode->val;
00217         else
00218                 return NULL;
00219 }

template<class T>
uint32 NL3D::COrderingTable< T >::getSize  ) 
 

Just return the number of entries in the ordering table

Definition at line 159 of file ordering_table.h.

References NL3D::COrderingTable< T >::_nNbElt, and uint32.

00160 {
00161         return _nNbElt;
00162 }

template<class T>
void NL3D::COrderingTable< T >::init uint32  nNbEntries  ) 
 

Initialization. The ordering table has a range from 0 to nNbEntries-1

Definition at line 146 of file ordering_table.h.

References NL3D::COrderingTable< T >::_Array, NL3D::COrderingTable< T >::_nNbElt, NL3D::COrderingTable< T >::reset(), and uint32.

00147 {
00148         if( _Array != NULL )
00149         {
00150                 reset(0);
00151                 delete [] _Array;
00152         }
00153         _nNbElt = nNbEntries;
00154         _Array = new CNode[_nNbElt];
00155         reset(0);
00156 }

template<class T>
void NL3D::COrderingTable< T >::insert uint32  nEntryPos,
T *  pValue
 

Insert an element in the ordering table NB: element is inserted in front of the list at nEntryPos (for optim consideration) NB: nlassert in debug if num of insert() calls exceed value passed in reset() NB: nlassert in debug if nEntryPos is => getSize()

Definition at line 183 of file ordering_table.h.

References NL3D::COrderingTable< T >::_Allocator, NL3D::COrderingTable< T >::_Array, NL3D::COrderingTable< T >::_CurAllocatedNode, NL3D::COrderingTable< T >::_nNbElt, NL3D::COrderingTable< T >::CNode::next, nlassert, uint32, and NL3D::COrderingTable< T >::CNode::val.

00184 {
00185 #ifdef NL_DEBUG
00186         // check not so many calls to insert()
00187         nlassert( !_Allocator.empty() && _CurAllocatedNode < (&_Allocator[0])+_Allocator.size() );
00188         // check good entry size
00189         nlassert( nEntryPos < _nNbElt );
00190 #endif
00191         // get the head list node
00192         CNode *headNode = &_Array[nEntryPos];
00193         // alocate a new node
00194         CNode *nextNode = _CurAllocatedNode++;
00195         // fill this new node with data of head node
00196         nextNode->val= headNode->val;
00197         nextNode->next= headNode->next;
00198         // and replace head node with new data: consequence is pValue is insert in front of the list
00199         headNode->val= pValue;
00200         headNode->next= nextNode;
00201         // NB: prec of headNode is still correclty linked to headNode.
00202 }

template<class T>
void NL3D::COrderingTable< T >::next  ) 
 

Move selection pointer to the next element

Definition at line 222 of file ordering_table.h.

References NL3D::COrderingTable< T >::_SelNode, NL3D::COrderingTable< T >::CNode::next, and NL3D::COrderingTable< T >::CNode::val.

Referenced by NL3D::COrderingTable< T >::begin().

00223 {
00224         _SelNode = _SelNode->next;
00225         while( ( _SelNode != NULL )&&( _SelNode->val == NULL ) )
00226                 _SelNode = _SelNode->next;
00227 }

template<class T>
void NL3D::COrderingTable< T >::reset uint  maxElementToInsert  ) 
 

Put the ordering table to empty

Parameters:
maxElementToInsert prepare allocator for insert by setting maximum insert() that will arise.

Definition at line 165 of file ordering_table.h.

References NL3D::COrderingTable< T >::_Allocator, NL3D::COrderingTable< T >::_Array, NL3D::COrderingTable< T >::_CurAllocatedNode, NL3D::COrderingTable< T >::_nNbElt, NL3D::COrderingTable< T >::CNode::next, uint, uint32, and NL3D::COrderingTable< T >::CNode::val.

Referenced by NL3D::COrderingTable< T >::init().

00166 {
00167         // reset allocation
00168         maxElementToInsert= max(1U, maxElementToInsert);
00169         _Allocator.resize(maxElementToInsert);
00170         _CurAllocatedNode= &_Allocator[0];
00171 
00172         // reset OT.
00173         for( uint32 i = 0; i < _nNbElt-1; ++i )
00174         {
00175                 _Array[i].val = NULL;
00176                 _Array[i].next = &_Array[i+1];
00177         }
00178         _Array[_nNbElt-1].val  = NULL;
00179         _Array[_nNbElt-1].next = NULL;
00180 }


Field Documentation

template<class T>
std::vector<CNode> NL3D::COrderingTable< T >::_Allocator [private]
 

Definition at line 120 of file ordering_table.h.

Referenced by NL3D::COrderingTable< T >::insert(), and NL3D::COrderingTable< T >::reset().

template<class T>
CNode* NL3D::COrderingTable< T >::_Array [private]
 

Definition at line 124 of file ordering_table.h.

Referenced by NL3D::COrderingTable< T >::begin(), NL3D::COrderingTable< T >::COrderingTable(), NL3D::COrderingTable< T >::init(), NL3D::COrderingTable< T >::insert(), NL3D::COrderingTable< T >::reset(), and NL3D::COrderingTable< T >::~COrderingTable().

template<class T>
CNode* NL3D::COrderingTable< T >::_CurAllocatedNode [private]
 

Definition at line 121 of file ordering_table.h.

Referenced by NL3D::COrderingTable< T >::COrderingTable(), NL3D::COrderingTable< T >::insert(), and NL3D::COrderingTable< T >::reset().

template<class T>
uint32 NL3D::COrderingTable< T >::_nNbElt [private]
 

Definition at line 123 of file ordering_table.h.

Referenced by NL3D::COrderingTable< T >::COrderingTable(), NL3D::COrderingTable< T >::getSize(), NL3D::COrderingTable< T >::init(), NL3D::COrderingTable< T >::insert(), and NL3D::COrderingTable< T >::reset().

template<class T>
CNode* NL3D::COrderingTable< T >::_SelNode [private]
 

Definition at line 125 of file ordering_table.h.

Referenced by NL3D::COrderingTable< T >::begin(), NL3D::COrderingTable< T >::COrderingTable(), NL3D::COrderingTable< T >::get(), and NL3D::COrderingTable< T >::next().


The documentation for this class was generated from the following file:
Generated on Tue Mar 16 06:57:23 2004 for NeL by doxygen 1.3.6