#include <heap.hpp>
Definition at line 39 of file heap.hpp.
heap_rep | ( | comparison | compare2 | ) | [inline] |
~heap_rep | ( | ) | [inline] |
void correct_downwards | ( | ) | [inline] |
Definition at line 117 of file heap.hpp.
References mmx::swap().
Referenced by heap_rep< C >::Pull(), and heap_rep< C >::Set_top().
00117 { 00118 nat i= 0; 00119 while (true) { 00120 nat l= (i<<1) + 1, r= l+1; 00121 if (l >= n) break; 00122 if (compare (a[i], a[l])) { 00123 if (r >= n || compare (a[i], a[r])) break; 00124 else { 00125 swap (a[i], a[r]); 00126 i= r; 00127 } 00128 } 00129 else { 00130 if (r >= n || compare (a[i], a[r]) || compare (a[l], a[r])) { 00131 swap (a[i], a[l]); 00132 i= l; 00133 } 00134 else { 00135 swap (a[i], a[r]); 00136 i= r; 00137 } 00138 } 00139 } 00140 }
void correct_upwards | ( | ) | [inline] |
Definition at line 143 of file heap.hpp.
References mmx::swap().
Referenced by heap_rep< C >::Push().
C Get_top | ( | ) | const [inline] |
C Pull | ( | ) | [inline] |
Definition at line 176 of file heap.hpp.
References ASSERT, mmx::C, heap_rep< C >::correct_downwards(), and heap_rep< C >::resize().
void Push | ( | const C & | x | ) | [inline] |
Definition at line 169 of file heap.hpp.
References heap_rep< C >::correct_upwards(), and heap_rep< C >::resize().
00169 { 00170 resize (n+1); 00171 a[n-1]= x; 00172 correct_upwards (); 00173 }
void resize | ( | nat | n2 | ) | [inline] |
Definition at line 103 of file heap.hpp.
References mmx::C, mmx::min(), and n.
Referenced by heap_rep< C >::Pull(), and heap_rep< C >::Push().
void Set_top | ( | const C & | x | ) | [inline] |
Definition at line 156 of file heap.hpp.
References ASSERT, and heap_rep< C >::correct_downwards().
00156 { 00157 ASSERT (n>0, "non-empty heap expected"); 00158 a[0]= x; 00159 correct_downwards (); 00160 }