00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef WM4TMINHEAP_H
00017 #define WM4TMINHEAP_H
00018
00019 #include "Wm4System.h"
00020
00021 namespace Wm4
00022 {
00023
00024 template <typename Generator, typename Real> class TMinHeap;
00025
00026 template <typename Generator, typename Real>
00027 class TMinHeapRecord
00028 {
00029 public:
00030 TMinHeapRecord ();
00031 ~TMinHeapRecord ();
00032
00033 Generator GetGenerator () const;
00034 Real GetValue () const;
00035
00036 private:
00037 friend class TMinHeap<Generator,Real>;
00038
00039 Generator m_tGenerator;
00040 Real m_fValue;
00041 int m_iIndex;
00042 };
00043
00044 template <typename Generator, typename Real>
00045 class TMinHeap
00046 {
00047 public:
00048 TMinHeap (int iMaxQuantity, int iGrowBy);
00049 ~TMinHeap ();
00050
00051
00052 int GetMaxQuantity () const;
00053 int GetGrowBy () const;
00054 int GetQuantity () const;
00055 const TMinHeapRecord<Generator,Real>* GetRecord (int i) const;
00056
00057
00058
00059
00060 const TMinHeapRecord<Generator,Real>* Insert (Generator tGenerator,
00061 Real fValue);
00062
00063
00064
00065
00066 void Remove (Generator& rtGenerator, Real& rfValue);
00067
00068
00069
00070
00071 void Update (const TMinHeapRecord<Generator,Real>* pkConstRecord,
00072 Real fValue);
00073
00074
00075
00076
00077 bool IsValid (int iStart, int iFinal);
00078 bool IsValid ();
00079 void Print (const char* acFilename);
00080
00081 private:
00082
00083 int m_iMaxQuantity, m_iGrowBy, m_iQuantity;
00084 TMinHeapRecord<Generator,Real>* m_akRecords;
00085
00086
00087
00088
00089 TMinHeapRecord<Generator,Real>** m_apkRecords;
00090 };
00091
00092 #include "Wm4TMinHeap.inl"
00093
00094 }
00095
00096 #endif