38 typename FirstHasHigherPriority = std::greater<T>>
52 FirstHasHigherPriority first_has_higher_priority_fn_;
74 const int final_heap_size =
data_.size();
75 if (final_heap_size > 1) {
76 for (
int64_t i = this->get_parent(final_heap_size - 1); i >= 0; i--) {
77 this->heapify(i, final_heap_size);
80 heap_size_ = final_heap_size;
98 return heap_size_ == 0;
127 return heap_to_orig_[0];
136 const int64_t top_index_orig = heap_to_orig_[0];
138 if (heap_size_ > 1) {
139 this->swap_indices(0, heap_size_);
140 this->heapify(0, heap_size_);
142 return top_index_orig;
151 const int64_t heap_index = orig_to_heap_[index];
152 if (heap_index >= heap_size_) {
156 this->heapify(heap_index, heap_size_);
165 int64_t current = orig_to_heap_[index];
166 if (current >= heap_size_) {
174 const int64_t parent = this->get_parent(current);
175 if (this->first_has_higher_priority(parent, current)) {
178 this->swap_indices(current, parent);
217 return heap_to_orig_;
226 return this->partial_to_dot(heap_size_);
232 const T &value_a =
data_[heap_to_orig_[
a]];
233 const T &value_b =
data_[heap_to_orig_[b]];
234 return first_has_higher_priority_fn_(value_a, value_b);
239 std::swap(heap_to_orig_[
a], heap_to_orig_[b]);
240 orig_to_heap_[heap_to_orig_[
a]] =
a;
241 orig_to_heap_[heap_to_orig_[b]] = b;
247 const int left = this->get_left(parent);
248 const int right = this->get_right(parent);
249 if (left < heap_size && this->first_has_higher_priority(
left, max_index)) {
252 if (right < heap_size && this->first_has_higher_priority(
right, max_index)) {
255 if (max_index != parent) {
256 this->swap_indices(parent, max_index);
257 this->heapify(max_index, heap_size);
259 if (
left < heap_size) {
262 if (
right < heap_size) {
270 return (child - 1) / 2;
275 return parent * 2 + 1;
280 return parent * 2 + 2;
283 std::string partial_to_dot(
const int size)
const
286 Array<dot::Node *> dot_nodes(
size);
287 for (
const int i : IndexRange(
size)) {
288 std::stringstream ss;
289 ss <<
data_[heap_to_orig_[i]];
290 const std::string name = ss.str();
292 node.set_shape(dot::Attr_shape::Rectangle);
293 node.attributes.set(
"ordering",
"out");
294 dot_nodes[i] = &
node;
296 const int64_t parent = this->get_parent(i);
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble right
Span< T > as_span() const
Span< int64_t > active_indices() const
Span< int64_t > inactive_indices() const
Span< int64_t > all_indices() const
std::string to_dot() const
void priority_decreased(const int64_t index)
InplacePriorityQueue(Span< T > data)
void priority_increased(const int64_t index)
int64_t peek_index() const
void priority_changed(const int64_t index)
constexpr Span drop_front(int64_t n) const
constexpr Span take_front(int64_t n) const
DirectedEdge & new_edge(NodePort from, NodePort to)
std::string to_dot_string() const
Node & new_node(StringRef label)