Main Page | User's guide | Class Hierarchy | Class List | File List | Class Members

list.hxx

00001 // Copyright (C) 2002-2004 Vivien Mallet
00002 //
00003 // This file is part of Multivac library.
00004 // Multivac library provides front-tracking algorithms.
00005 // 
00006 // Multivac is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 2 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // Multivac is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License (file "license") for more details.
00015 //
00016 // For more information, please see the Multivac home page:
00017 //     http://spacetown.free.fr/fronts/
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   // CELL //
00044 
00046   template <class T>
00047   class Cell
00048   {
00049     
00050     /************************
00051      * TYPEDEF DECLARATIONS *
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      * ATTRIBUTES *
00064      **************/
00065     
00066   protected:
00068     T X_;
00070     Cell<T>* previous_;
00072     Cell<T>* next_;
00073 
00074 
00075     /**********
00076      * METHOD *
00077      **********/
00078 
00079   public:
00080     //Constructor.
00081     Cell()  throw();
00082     Cell(T& X, Cell<T>* previous, Cell<T>* next)  throw();
00083 
00084     // Destructor.
00085     ~Cell()  throw();
00086 
00087     // Basic methods.
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      * FRIEND *
00102      **********/
00103 
00104     friend class List<T>;
00105 
00106   };  // Cell.
00107 
00108   
00110   // LIST //
00112 
00114   template <class T>
00115   class List: public SpaceTown
00116   {
00117 
00118     /************************
00119      * TYPEDEF DECLARATIONS *
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      * ATTRIBUTES *
00132      **************/
00133 
00134   protected:
00136     Cell<T>* head_;
00138     Cell<T>* current_;
00140     Cell<T>* tail_;
00141 
00142 
00143     /***********
00144      * METHODS *
00145      ***********/
00146 
00147   public:
00148     //Constructor.
00149     List()  throw();
00150     List(const List<T>&)  throw();
00151 
00152     // Destructor.
00153     ~List()  throw();
00154 
00155     // Initializations.
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     // Convenient functions.
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   };  // List.
00188 
00189 
00190 }  // namespace Multivac.
00191 
00192 
00193 #define FILE_LIST_HXX
00194 #endif

Generated on Mon Apr 19 01:59:14 2004 for Multivac by doxygen 1.3.6-20040222