1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
template<class T>
class IterListe{
private:
ListeTrie<T> liste;
Noeud<T> *noeud;
public:
IterListe<T>(ListeTrie<T>& l);
bool end();
void reset();
bool operator++();
bool operator++(int);
operator T();
T& operator& ();
};
template <class T>
IterListe<T>::IterListe(ListeTrie<T>& l)
{
liste = l;
noeud = &(l.first);
}
template <class T>
bool IterListe<T>::end()
{
return noeud == NULL;
}
template <class T>
void IterListe<T>::reset()
{
noeud = &(liste.first);
}
template <class T>
bool IterListe<T>::operator++()
{
if((noeud = noeud->hasNext())==NULL)
return false;
else
return true;
}
template <class T>
bool IterListe<T>::operator++(int i)
{
return operator++();
}
template <class T>
IterListe<T>::operator T()
{
return noeud->getData();
}
template <class T>
T& IterListe<T>::operator&()
{
return noeud->getData();
} |
Partager