Your_Class::Sort
By default, the "Sort()" method sort all the children of a class using the "Compare()" method, you can override this method.
Syntax
int Your_Class::Sort(
unsigned char recurs
)
Parameters
recurs
A flag indicating if the method will also recursively sort the children of the class
Return value
This method returns "0" if an error occurred, "1" otherwise.
Remarks
Requirements
Header:
sliceO_include.hpp
Library:
sliceO_Structures.lib
Example
The default method
|
// ----------------------------------------------------------------------------
//
// Sort()
//
// Sort all the children pointers
//
// param: (void)
//
// return: (int) 1 if success
//
// ----------------------------------------------------------------------------
int SliceO_Class::Sort( unsigned char recurs )
{
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