160 if (p < minimal) { |
160 if (p < minimal) { |
161 minimal = p; |
161 minimal = p; |
162 } |
162 } |
163 } |
163 } |
164 |
164 |
165 /// \brief Returns the item with minimum priority relative to \c Compare. |
165 /// \brief Returns the item with minimum priority. |
166 /// |
166 /// |
167 /// This method returns the item with minimum priority relative to \c |
167 /// This method returns the item with minimum priority. |
168 /// Compare. |
|
169 /// \pre The heap must be nonempty. |
168 /// \pre The heap must be nonempty. |
170 Item top() const { |
169 Item top() const { |
171 while (first[minimal] == -1) { |
170 while (first[minimal] == -1) { |
172 ++minimal; |
171 ++minimal; |
173 } |
172 } |
174 return data[first[minimal]].item; |
173 return data[first[minimal]].item; |
175 } |
174 } |
176 |
175 |
177 /// \brief Returns the minimum priority relative to \c Compare. |
176 /// \brief Returns the minimum priority. |
178 /// |
177 /// |
179 /// It returns the minimum priority relative to \c Compare. |
178 /// It returns the minimum priority. |
180 /// \pre The heap must be nonempty. |
179 /// \pre The heap must be nonempty. |
181 Prio prio() const { |
180 Prio prio() const { |
182 while (first[minimal] == -1) { |
181 while (first[minimal] == -1) { |
183 ++minimal; |
182 ++minimal; |
184 } |
183 } |
185 return minimal; |
184 return minimal; |
186 } |
185 } |
187 |
186 |
188 /// \brief Deletes the item with minimum priority relative to \c Compare. |
187 /// \brief Deletes the item with minimum priority. |
189 /// |
188 /// |
190 /// This method deletes the item with minimum priority relative to \c |
189 /// This method deletes the item with minimum priority from the heap. |
191 /// Compare from the heap. |
|
192 /// \pre The heap must be non-empty. |
190 /// \pre The heap must be non-empty. |
193 void pop() { |
191 void pop() { |
194 while (first[minimal] == -1) { |
192 while (first[minimal] == -1) { |
195 ++minimal; |
193 ++minimal; |
196 } |
194 } |