This method sort all its children using the "Compare" method.
Syntax
int Sort(
unsigned char recurs
) ;
Parameters
recurs
If "1" then the method should recursively call all its children.
Return value
This method return "0" is an error occurred.
Remarks
Requirements
Header:
sliceO_include.hpp
Library:
sliceO_Structures.lib
Example
Default "Sort" method of the SliceO_Class class.
|
// ----------------------------------------------------------------------------
//
// Sort()
//
// Sort all the children pointers
//
// param: (void)
//
// return: (int) 1 if success
//
// ----------------------------------------------------------------------------
int SliceO_Class::Sort( unsigned char recurs )
{
VALIDITY_TEST_CLASS( this, "SliceO_Class::Sort" ) ;
// --- Simple bibble sort ---
for ( int i=0; i < m_child_nb-1; i++ )
for ( int j=i+1; j < m_child_nb; j++ )
if ( m_child_pt[i]->Compare( m_child_pt[j] ) > 0 ) {
SliceO_Class *mom = m_child_pt[i] ;
m_child_pt[i] = m_child_pt[j] ;
m_child_pt[j] = mom ;
}
if ( recurs )
for ( int k=0; k < m_child_nb; k++ )
m_child_pt[k]->Sort( recurs ) ;
return( 1 ) ;
}
|
|
See also