#include <CtrlLib/CtrlLib.h>

using namespace Upp;


class Table {

	public :
		Table( ) ;
		~Table( ) ;
		
	private :
	    typedef struct {
	        long Index ;
	        Array<long> Element ;
	    } ElementTable ;
		Array<ElementTable> LaTable ;
		
		static bool TrierTable( ElementTable a, ElementTable b ) ;
} ;

Table::Table( )
{
	ElementTable UnElt ;
	
	RLOG( "Table non triee :" ) ;
	for( int Indice = 0 ; Indice < 50 ; Indice++ )
	{
		UnElt.Element.Clear( ) ;
		UnElt.Index = 50 + 2 * Indice ;
		UnElt.Element.Add( 3 * Indice ) ;
		UnElt.Element.Add( 3 * Indice + 1 ) ;
		LaTable.Add( UnElt ) ;
		RLOG( Format( "Table[%d] = %d - (%d,%d)",
		      Indice, int( LaTable.At( Indice ).Index ),
		      int( LaTable.At( Indice ).Element[0] ), int( LaTable.At( Indice ).Element[1] ) ) ) ;
	}

	Sort( LaTable, &TrierTable ) ;

	RLOG( Format( "Table triee : %d elements", LaTable.GetCount( ) ) ) ;
	for( int Indice = 0 ; Indice < 50 ; Indice++ )
	{
		RLOG( Format( "Table[%d] = %d", Indice, int( LaTable.At( Indice ).Index ) ) ) ;
		RLOG( Format( "Table[%d].Element = %d", Indice, int( LaTable.At( Indice ).Element.GetCount( ) ) ) ) ;
//		RLOG( Format( "Table[%d] = %d - (%d,%d)",
//		      Indice, int( LaTable.At( Indice ).Index ),
//		      int( LaTable.At( Indice ).Element[0] ), int( LaTable.At( Indice ).Element[1] ) ) ) ;
	}
	
}

Table::~Table( )
{
	LaTable.Clear( ) ;
}


bool Table::TrierTable( ElementTable a, ElementTable b )
{
	if( a.Index < b.Index )
		return false ;
	else
		return true ;
}

int main(int argc, const char *argv[])
{
	Table MaTable ;

	return 0;
}

