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

/**
 *
 * @File : Exo_04Bis.hxx
 *
 * @Authors : D. Mathieu
 *
 * @Date : 08/03/2000
 *
 * @Version :
 *
 * @Synopsis :
 *
 **/
#if !defined __EXO_04BIS_HXX__
#define      __EXO_04BIS_HXX__

#include <iostream>
#include <climits>
#include <algorithm>

#include "CListe.h"
#include "CCptIdent.h"

using namespace std;

namespace
{
    struct SMinMax
    {
        unsigned Min;
        unsigned Max;
    };

    void MinMax (CCptIdent & Element, SMinMax * Param)
    {
        Param->Min = min (Param->Min, Element.GetFreq ());
        Param->Max = max (Param->Max, Element.GetFreq ());

    } // MinMax()

    inline void Exo_04Bis (void)
    {
        cout << "Exo_04Bis : \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"))));

        UneListe.ForEach (Editer);

        SMinMax LesMinMax = {INT_MAX, 0};
        UneListe.ForEach ((CListeIdent::Fct2_t) MinMax, &LesMinMax);
        cout << "Frequence minimale : " << LesMinMax.Min << endl;
        cout << "Frequence maximale : " << LesMinMax.Max << endl;

    } // Exo_04Bis()

} // namespace

#endif // __EXO_04BIS_HXX__