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

arrayheap.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_ARRAYHEAP_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   
00038   // ARRAYHEAP //
00040 
00041   template <class T>
00042   class ArrayHeap: public SpaceTown
00043   {
00044 
00045     /************************
00046      * TYPEDEF DECLARATIONS *
00047      ************************/
00048 
00049   public:
00050     typedef T value_type;
00051     typedef T* pointer;
00052     typedef const T* const_pointer;
00053     typedef T& reference;
00054     typedef const T& const_reference;
00055 
00056 
00057     /**************
00058      * ATTRIBUTES *
00059      **************/
00060 
00061   protected:
00063     Vector<T*> Nodes;
00065     int NbNodes;
00066 
00067 
00068     /***********
00069      * METHODS *
00070      ***********/
00071 
00072   public:
00073     //Constructors.
00074     ArrayHeap()  throw();
00075     ArrayHeap(int depth)  throw();
00076 
00077     // Destructor.
00078     ~ArrayHeap()  throw();
00079 
00080     // Initializations.
00081     void Reallocate(int length);
00082     void Resize(int length, int lastelement = 0);
00083 
00084     int Add(T* X);
00085     int Add(T* X, Matrix<int>& Pointers);
00086     int MoveUp(int XIndex);
00087     int MoveUp(int XIndex, Matrix<int>& Pointers);
00088 
00089     void DeleteRoot();
00090     void DeleteRoot(Matrix<int>& Pointers);
00091 
00092     // Convenient functions.
00093     T* operator() (int i);
00094 
00095     T* GetRoot();
00096     T* GetRoot() const;
00097 
00098     int GetNbNodes() const;
00099     bool IsEmpty() const;
00100 
00101   };  // ArrayHead.
00102 
00103 
00104 }  // namespace Multivac.
00105 
00106 
00107 #define FILE_ARRAYHEAP_HXX
00108 #endif

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