filters
listeformat.cc00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <kdebug.h>
00028 #include "listeformat.h"
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 FormatElt::~FormatElt()
00040 {
00041 kdDebug(30522) << "Destruction d'un elementT" << endl;
00042 remFormat();
00043 }
00044
00045
00046
00047
00048 void FormatElt::setFormat(Format* format)
00049 {
00050 _format = format;
00051 }
00052
00053 void FormatElt::remFormat()
00054 {
00055 delete _format;
00056 _format = 0;
00057 }
00058
00059 void FormatElt::setNext(FormatElt* next)
00060 {
00061 _next = next;
00062 }
00063
00064 void FormatElt::remNext()
00065 {
00066 delete _next;
00067 _next = 0;
00068 }
00069
00070
00071 FormatElt& FormatElt::operator = (const FormatElt & elt)
00072 {
00073 _format = elt.getFormat();
00074 _next = elt.getNext();
00075 return *this;
00076 }
00077
00079 ListeFormat::ListeFormat()
00080 {
00081 kdDebug(30522) << "Create format list" << endl;
00082 _first = 0;
00083 _end = 0;
00084 _size = 0;
00085 }
00086
00087 ListeFormat::~ListeFormat()
00088 {
00089 kdDebug(30522) << "Destruction of a list of format" << endl;
00090 vider();
00091 kdDebug(30522) << "ok" << endl;
00092 }
00093
00094 void ListeFormat::addLast(Format *elt)
00095 {
00096
00097 FormatElt *new_last = new FormatElt;
00098
00099 new_last->setFormat(elt);
00100
00101 if(_first != 0)
00102 {
00103 _end->setNext(new_last);
00104 _end = new_last;
00105 }
00106 else
00107 {
00108
00109 _end = new_last;
00110 _first = _end;
00111 }
00112 _size = _size + 1;
00113 }
00114
00115 void ListeFormat::addFirst(Format* elt)
00116 {
00117 FormatElt *new_first = new FormatElt;
00118
00119 new_first->setFormat(elt);
00120 new_first->setNext(_first);
00121
00122 _first = new_first;
00123 if(_size == 0)
00124 {
00125
00126 _end = _first;
00127 }
00128 _size = _size + 1;
00129 }
00130
00131 void ListeFormat::remLast()
00132 {
00133 FormatElt *new_last = new FormatElt(_first);
00134
00135 for(int index = 1; index< _size - 1; new_last = new_last->getNext())
00136 { }
00137
00138 delete _end;
00139 _end = new_last;
00140 _size = _size - 1;
00141 }
00142
00143 void ListeFormat::remFirst()
00144 {
00145 FormatElt *first_saved;
00146
00147 first_saved = _first->getNext();
00148
00149 delete _first;
00150 _first = first_saved;
00151 _size = _size - 1;
00152 }
00153
00154 void ListeFormat::vider()
00155 {
00156 while(_first != 0)
00157 {
00158 remFirst();
00159 }
00160 }
00161
|