00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef FILE_LIST_HXX
00021
00022
00023 #include "errors.cxx"
00024
00025 #include <iostream>
00026 using std::cout;
00027 using std::endl;
00028 #include <stdlib.h>
00029 #include <time.h>
00030 #include <stdio.h>
00031
00032
00033 namespace Multivac
00034 {
00035
00036
00037 template <class T>
00038 class List;
00039
00040
00042
00044
00046 template <class T>
00047 class Cell
00048 {
00049
00050
00051
00052
00053
00054 public:
00055 typedef T value_type;
00056 typedef T* pointer;
00057 typedef const T* const_pointer;
00058 typedef T& reference;
00059 typedef const T& const_reference;
00060
00061
00062
00063
00064
00065
00066 protected:
00068 T X_;
00070 Cell<T>* previous_;
00072 Cell<T>* next_;
00073
00074
00075
00076
00077
00078
00079 public:
00080
00081 Cell() throw();
00082 Cell(T& X, Cell<T>* previous, Cell<T>* next) throw();
00083
00084
00085 ~Cell() throw();
00086
00087
00088 const_reference GetElement() const;
00089 reference GetElement();
00090 void GetElement(T& X) const;
00091 void SetElement(T& X);
00092
00093 Cell<T>* GetPrevious() const;
00094 void SetPrevious(Cell<T>* previous);
00095
00096 Cell<T>* GetNext() const;
00097 void SetNext(Cell<T>* next);
00098
00099
00100
00101
00102
00103
00104 friend class List<T>;
00105
00106 };
00107
00108
00110
00112
00114 template <class T>
00115 class List: public SpaceTown
00116 {
00117
00118
00119
00120
00121
00122 public:
00123 typedef T value_type;
00124 typedef T* pointer;
00125 typedef const T* const_pointer;
00126 typedef T& reference;
00127 typedef const T& const_reference;
00128
00129
00130
00131
00132
00133
00134 protected:
00136 Cell<T>* head_;
00138 Cell<T>* current_;
00140 Cell<T>* tail_;
00141
00142
00143
00144
00145
00146
00147 public:
00148
00149 List() throw();
00150 List(const List<T>&) throw();
00151
00152
00153 ~List() throw();
00154
00155
00156 void Init();
00157 void Copy(const List<T>&);
00158
00159 void AddAtTheEnd(T& X);
00160 void AddAtTheEnd(Cell<T>* NewTail);
00161
00162 void Reverse();
00163
00164 Cell<T>* RemoveCurrent();
00165 void DeleteCurrent();
00166 Cell<T>* Remove(Cell<T>* cell);
00167 void ClearAll();
00168
00169
00170 const_reference GetHeadValue() const;
00171 const_reference GetCurrentValue() const;
00172 const_reference GetTailValue() const;
00173
00174 reference GetHeadValue();
00175 reference GetCurrentValue();
00176 reference GetTailValue();
00177
00178 Cell<T>* GetCurrent() const;
00179
00180 void GoToTheHead();
00181 void GoToTheTail();
00182
00183 bool GoToNext_StopAtTheTail();
00184
00185 bool IsEmpty() const;
00186
00187 };
00188
00189
00190 }
00191
00192
00193 #define FILE_LIST_HXX
00194 #endif