00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00040
00041 template <class T>
00042 class ArrayHeap: public SpaceTown
00043 {
00044
00045
00046
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
00059
00060
00061 protected:
00063 Vector<T*> Nodes;
00065 int NbNodes;
00066
00067
00068
00069
00070
00071
00072 public:
00073
00074 ArrayHeap() throw();
00075 ArrayHeap(int depth) throw();
00076
00077
00078 ~ArrayHeap() throw();
00079
00080
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
00093 T* operator() (int i);
00094
00095 T* GetRoot();
00096 T* GetRoot() const;
00097
00098 int GetNbNodes() const;
00099 bool IsEmpty() const;
00100
00101 };
00102
00103
00104 }
00105
00106
00107 #define FILE_ARRAYHEAP_HXX
00108 #endif