#include <TableauDyn.h>
Inheritance diagram for TableauDyn< T >:
Public Member Functions | |
TableauDyn () | |
Constructeur par défaut. | |
TableauDyn (int nb) | |
Construction d'un tablea de nb éléments. | |
TableauDyn (const TableauDyn< T > &l) | |
Constructeur par recopie. | |
~TableauDyn () | |
TableauDyn< T > & | Cons (T val, int pos) |
Ajout de val à la position pos. | |
TableauDyn< T > & | ConsTete (T val) |
Ajout de val en tête. | |
TableauDyn< T > & | ConsQueue (T val) |
Ajout de val en queue. | |
void | Modifier (int pos, T elt) |
Modification de l'élément en pos par T. | |
void | SetTaille (unsigned int nb) |
Définir la taille du tableau (si connue) Evite les réalocations multiples. | |
TableauDyn< T > & | Detruit (unsigned int i) |
Destruction de l'élément i. | |
TableauDyn< T > & | DetruitVirtuel (unsigned int pos) |
Destruction virtuel, ne fait que décrémenter le cardinal du tableau A n'utiliser qu'en des cas très précis !. | |
unsigned int | Card () const |
Retourne le nombre d'élément du tableau. | |
T | Tete () const |
Accéder à la tête de la liste. | |
T | Valeur (int i) const |
Accesseur de la ième valeur. | |
T | operator[] (int i) const |
Surcharge de []. | |
void | Afficher () const |
Affichage du tableau. | |
const TableauDyn< T > & | operator= (const TableauDyn< T > &l) |
Surcharge de =. | |
Protected Attributes | |
T * | mTab |
Tableau dynamique. | |
int | mCard |
Nombre de valeurs alloués. |
Definition at line 14 of file TableauDyn.h.
TableauDyn< T >::TableauDyn | ( | ) |
Constructeur par défaut.
Definition at line 146 of file TableauDyn.h.
References TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
TableauDyn< T >::TableauDyn | ( | int | nb | ) |
Construction d'un tablea de nb éléments.
nb | Nombre d'éléments du tableau |
Definition at line 151 of file TableauDyn.h.
References TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
TableauDyn< T >::TableauDyn | ( | const TableauDyn< T > & | l | ) |
Constructeur par recopie.
l | TableauDyn de base |
Definition at line 156 of file TableauDyn.h.
References TableauDyn< T >::Card(), TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
00156 { 00157 delete [] mTab; 00158 mCard=l.Card(); 00159 mTab=new T [mCard]; 00160 for(unsigned int i=0; i<l.Card(); i++){ 00161 mTab[i]=l[i]; 00162 } 00163 }
Here is the call graph for this function:
TableauDyn< T >::~TableauDyn | ( | ) |
Definition at line 166 of file TableauDyn.h.
References TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
TableauDyn< T > & TableauDyn< T >::Cons | ( | T | val, | |
int | pos | |||
) |
Ajout de val à la position pos.
val | Valeur à ajouter | |
pos | Indice d'insertion |
Definition at line 172 of file TableauDyn.h.
References TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
Referenced by TableauDyn< T >::ConsQueue(), and TableauDyn< T >::ConsTete().
00172 { 00173 //Allocation du tableau temporaire 00174 T *tab=new T[mCard+1]; 00175 //Recopie jusqu pos 00176 for(int i=0; i<pos; i++){ 00177 tab[i]=mTab[i]; 00178 } 00179 //Construction en pos de la valeur 00180 tab[pos]=val; 00181 //Recopie du reste 00182 for(int i=pos; i<mCard; i++){ 00183 tab[i+1]=mTab[i]; 00184 } 00185 //Desctruction de l'ancien tableau 00186 delete[] mTab; 00187 //Nouvelle allocation 00188 mTab=new T[mCard+1]; 00189 //Recopie 00190 for(int i=0; i<mCard+1; i++){ 00191 mTab[i]=tab[i]; 00192 } 00193 mCard++; 00194 //Destruction du tableau temporaire 00195 delete[] tab; 00196 return (*this); 00197 }
TableauDyn< T > & TableauDyn< T >::ConsTete | ( | T | val | ) |
Ajout de val en tête.
val | Valeur à ajouter |
Definition at line 199 of file TableauDyn.h.
References TableauDyn< T >::Cons().
00199 { 00200 Cons(val,0); 00201 return (*this); 00202 }
Here is the call graph for this function:
TableauDyn< T > & TableauDyn< T >::ConsQueue | ( | T | val | ) |
Ajout de val en queue.
val | Valeur à ajouter |
Definition at line 204 of file TableauDyn.h.
References TableauDyn< T >::Cons(), and TableauDyn< T >::mCard.
Referenced by Partie::AjouterPartie(), BdD::AjouterUtilisateur(), ServeurPrincipal::AttendreClient(), and BdD::Charger().
Here is the call graph for this function:
void TableauDyn< T >::Modifier | ( | int | pos, | |
T | elt | |||
) |
Modification de l'élément en pos par T.
pos | Indice de l'élément à modifier | |
elt | Nouvel élément |
Definition at line 209 of file TableauDyn.h.
References TableauDyn< T >::mTab.
Referenced by Partie::SetLoginF(), Partie::SetLoginPacman(), Partie::SetNbFantomeAuto(), BdD::SetScore(), Partie::SetScoreF(), and Partie::SetScorePacman().
00209 { 00210 mTab[pos]=elt; 00211 }
void TableauDyn< T >::SetTaille | ( | unsigned int | nb | ) |
Définir la taille du tableau (si connue)
Evite les réalocations multiples.
nb | Taille du tableau |
Definition at line 213 of file TableauDyn.h.
References TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
TableauDyn< T > & TableauDyn< T >::Detruit | ( | unsigned int | i | ) |
Destruction de l'élément i.
i | Elément à détruire |
Definition at line 225 of file TableauDyn.h.
References TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
Referenced by Partie::SupprimerPartie(), and BdD::SupprimerUtilisateur().
00225 { 00226 T *tab=new T[mCard-1]; 00227 //on recopie tout sauf pos 00228 int k=0; 00229 for(int i=0; i<mCard; i++){ 00230 if(i!=pos){ 00231 tab[k]=mTab[i]; 00232 k++; 00233 } 00234 } 00235 //on supprime mTab 00236 delete[] mTab; 00237 mTab=new T[mCard-1]; 00238 for(int i=0; i<mCard-1; i++){ 00239 mTab[i]=tab[i]; 00240 } 00241 //on supprime tab 00242 delete[] tab; 00243 if(mCard>0) mCard--; 00244 return (*this); 00245 }
TableauDyn< T > & TableauDyn< T >::DetruitVirtuel | ( | unsigned int | pos | ) |
Destruction virtuel, ne fait que décrémenter le cardinal du tableau
A n'utiliser qu'en des cas très précis !.
pos |
Definition at line 220 of file TableauDyn.h.
References TableauDyn< T >::mCard.
00220 { 00221 mCard--; 00222 return (*this); 00223 }
unsigned int TableauDyn< T >::Card | ( | ) | const |
Retourne le nombre d'élément du tableau.
Definition at line 247 of file TableauDyn.h.
References TableauDyn< T >::mCard.
Referenced by Partie::Afficher(), BdD::Afficher(), BdD::ListeScore(), TableauDyn< T >::operator=(), Partie::Rechercher(), BdD::Rechercher(), BdD::Sauvegarder(), TableauDyn< T >::TableauDyn(), and Partie::ToString().
00247 { 00248 return mCard; 00249 }
T TableauDyn< T >::Tete | ( | ) | const |
Accéder à la tête de la liste.
Definition at line 250 of file TableauDyn.h.
References TableauDyn< T >::mTab.
00250 { 00251 return mTab[0]; 00252 }
T TableauDyn< T >::Valeur | ( | int | i | ) | const |
Accesseur de la ième valeur.
i | Valeur à retourner |
Definition at line 253 of file TableauDyn.h.
References TableauDyn< T >::mTab.
00253 { 00254 return mTab[i]; 00255 }
T TableauDyn< T >::operator[] | ( | int | i | ) | const |
Surcharge de [].
i | Valeur à retourner |
Definition at line 256 of file TableauDyn.h.
References TableauDyn< T >::mTab.
00256 { 00257 return mTab[i]; 00258 }
void TableauDyn< T >::Afficher | ( | ) | const |
Affichage du tableau.
Definition at line 259 of file TableauDyn.h.
References TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
const TableauDyn< T > & TableauDyn< T >::operator= | ( | const TableauDyn< T > & | l | ) |
Surcharge de =.
l | Tableau de base |
Definition at line 265 of file TableauDyn.h.
References TableauDyn< T >::Card(), TableauDyn< T >::mCard, and TableauDyn< T >::mTab.
00265 { 00266 delete [] mTab; 00267 mCard=l.Card(); 00268 mTab=new T [mCard]; 00269 for(unsigned int i=0; i<l.Card(); i++){ 00270 mTab[i]=l[i]; 00271 } 00272 return (*this); 00273 }
Here is the call graph for this function:
T* TableauDyn< T >::mTab [protected] |
Tableau dynamique.
Definition at line 136 of file TableauDyn.h.
Referenced by TableauDyn< T >::Afficher(), TableauDyn< T >::Cons(), TableauDyn< T >::Detruit(), TableauDyn< T >::Modifier(), TableauDyn< T >::operator=(), TableauDyn< T >::operator[](), TableauDyn< T >::SetTaille(), TableauDyn< T >::TableauDyn(), TableauDyn< T >::Tete(), TableauDyn< T >::Valeur(), and TableauDyn< T >::~TableauDyn().
int TableauDyn< T >::mCard [protected] |
Nombre de valeurs alloués.
Definition at line 141 of file TableauDyn.h.
Referenced by TableauDyn< T >::Afficher(), TableauDyn< T >::Card(), TableauDyn< T >::Cons(), TableauDyn< T >::ConsQueue(), TableauDyn< T >::Detruit(), TableauDyn< T >::DetruitVirtuel(), TableauDyn< T >::operator=(), TableauDyn< T >::SetTaille(), TableauDyn< T >::TableauDyn(), and TableauDyn< T >::~TableauDyn().