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
|
template <class TEMP, class ID>
class CListeChainee
{
private:
CListeChainee *m_next;
TEMP m_value;
ID m_ID;
public:
CListeChainee()
{
m_next = 0;
}
~CListeChainee()
{
FreeAll();
}
void FreeAll()
{
while (m_next)
m_next->FreeAll();
delete m_next;
m_next = 0;
}
//Ajout au bout de la liste
void Add(TEMP p_value, ID p_ID)
{
//Si mon ID est vide, je le mets ici
if (m_ID == NULL)
{
m_value = p_value;
m_ID = p_ID;
}
else
{
//Sinon je cree suivant et je lance recursivement Add dessus
if(!m_next)
m_next = new CListeChainee();
[b]m_next->Add(p_value, p_ID);[/b] }
}
}; |
Partager