// Seule la partie en caractères gras est demandée

/**
 *
 * @File : Exo_06Bis.hxx
 *
 * @Authors : D. Mathieu
 *
 * @Date : 15/03/2000
 *
 * @Version :
 *
 * @Synopsis :
 *
 **/
#if !defined __EXO_06BIS_HXX__
#define      __EXO_06BIS_HXX__

#include <iostream>
#include <algorithm>   // min(), max()
#include <climits>     // INT_MAX

#include "CListe.h"
#include "CCptIdent.h"
#include "CFunctorGen.h"
#include "CDumpable.h"

namespace
{
    class CMinMax : public CFunctor1Param <CCptIdent>, public CDumpable
    {
        unsigned m_Min;
        unsigned m_Max;

        virtual ostream & Dump (ostream & os) const
        {
            return os << "Frequence minimale : " << m_Min << endl
                      << "Frequence maximale : " << m_Max << endl;
        } // Dump()

      public :
        CMinMax (void) : m_Min (INT_MAX), m_Max (0) {}
        virtual void operator () (CCptIdent & Element)
        {
            m_Min = min (m_Min, Element.GetFreq ());
            m_Max = max (m_Max, Element.GetFreq ());
        }

    }; // CMinMax

    inline void Exo_06Bis (void)
    {
        cout << "Exo_06Bis : \n\n";

        typedef CListe <CCptIdent> CListeIdent;

        CListeIdent UneListe;

        cout << "Affichage de la liste" << endl;

        ++(*(UneListe.Look (string ("Ch1"))));
        ++(*(UneListe.Look (string ("Ch2"))));
        ++(*(UneListe.Look (string ("Ch3"))));
        ++(*(UneListe.Look (string ("Ch1"))));
        ++(*(UneListe.Look (string ("Ch2"))));
        ++(*(UneListe.Look (string ("Ch5"))));
        ++(*(UneListe.Look (string ("Ch5"))));
        ++(*(UneListe.Look (string ("Ch5"))));
        ++(*(UneListe.Look (string ("Ch5"))));
        ++(*(UneListe.Look (string ("Ch4"))));

        CMinMax MinMax;
        UneListe.ForEach (MinMax);

        cout << MinMax << endl;

    } // Exo_06Bis()

} // namespace

#endif // __EXO_06BIS_HXX__