00001
00029 #ifndef ABA_BPRIOQUEUE_INC
00030 #define ABA_BPRIOQUEUE_INC
00031
00032 template<class Type, class Key>
00033 ABA_BPRIOQUEUE<Type, Key>::ABA_BPRIOQUEUE(ABA_GLOBAL *glob, int size)
00034 :
00035 glob_(glob),
00036 heap_(glob, size)
00037 { }
00038
00039 template<class Type, class Key>
00040 void ABA_BPRIOQUEUE<Type, Key>::insert(Type elem, Key key)
00041 {
00042 heap_.insert(elem, key);
00043 }
00044
00045 template<class Type, class Key>
00046 int ABA_BPRIOQUEUE<Type, Key>::getMin(Type &min) const
00047 {
00049 if (heap_.empty()) return 1;
00050
00051 min = heap_.getMin();
00052 return 0;
00053 }
00054
00055 template<class Type, class Key>
00056 int ABA_BPRIOQUEUE<Type, Key>::getMinKey(Key &minKey) const
00057 {
00059 if (heap_.empty()) return 1;
00060
00061 minKey = heap_.getMinKey();
00062 return 0;
00063 }
00064
00065 template<class Type, class Key>
00066 int ABA_BPRIOQUEUE<Type, Key>::extractMin(Type& min)
00067 {
00069 if (heap_.empty()) return 1;
00070
00071 min = heap_.extractMin();
00072 return 0;
00073 }
00074
00075 template<class Type, class Key>
00076 void ABA_BPRIOQUEUE<Type, Key>::clear()
00077 {
00078 heap_.clear();
00079 }
00080
00081 template<class Type, class Key>
00082 inline int ABA_BPRIOQUEUE<Type, Key>::size() const
00083 {
00084 return heap_.size();
00085 }
00086
00087 template<class Type, class Key>
00088 inline int ABA_BPRIOQUEUE<Type, Key>::number() const
00089 {
00090 return heap_.number();
00091 }
00092
00093 template<class Type, class Key>
00094 void ABA_BPRIOQUEUE<Type, Key>::realloc(int newSize)
00095 {
00096 if (newSize < size()) {
00097 glob_->err() << "ABA_BPRIOQUEUE::realloc : priority queue cannot be decreased" << endl;
00098 exit(Fatal);
00099 }
00100
00101 heap_.realloc(newSize);
00102 }
00103
00104 #endif //ABA_BPRIOQUEUE_INC