Go to the documentation of this file.00001
00002
00003
00007 #ifndef __creaImageIOIndexedHeap_h_INCLUDED__
00008 #define __creaImageIOIndexedHeap_h_INCLUDED__
00009
00010 #include <vector>
00011
00012 namespace creaImageIO
00013 {
00014
00015
00016
00017 template <class T,
00018 class Comparator,
00019 class Indexer>
00020 class IndexedHeap ;
00021 template < class T,
00022 class C,
00023 class I>
00024 std::ostream& operator << (std::ostream&, const IndexedHeap<T,C,I>& );
00025
00026
00027
00028
00029
00030
00046 template <class T,
00047 class Comparator ,
00048 class Indexer >
00049 class IndexedHeap
00050 {
00051
00052 public :
00053
00054
00056 IndexedHeap () {}
00058 IndexedHeap ( const Comparator& comp, const Indexer& ind ) ;
00060 ~IndexedHeap() { }
00062 void set( const Comparator& comp );
00064 void set( const Indexer& ind );
00065
00066
00067
00069 int insert(T);
00071 T& top();
00073 const T& top() const;
00075 T remove_top();
00077 T remove(int n);
00079 inline int size() const {return m_p.size(); }
00081 void clear();
00082
00083
00084
00086 const std::vector<T> & stack() const {return m_p;}
00088 T& operator [] (int i) { return m_p[i];}
00090 const T& operator [] (int i) const { return m_p[i];}
00092 inline int index(T& t) { return (*m_i)(t); }
00093
00094
00095
00097 inline int father( int i ) const;
00099 inline int rightson( int i ) const;
00101 inline int leftson( int i ) const;
00102
00104 inline void swap(int i, int j);
00107 inline int upsort(int);
00110 inline int downsort(int);
00111
00112
00113 protected :
00115 std::vector<T> m_p;
00117 const Comparator* m_c;
00119 const Indexer* m_i;
00120 };
00121
00122
00123
00124
00125
00126 #include "creaImageIOIndexedHeap.txx"
00127
00128
00129 };
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139 #endif