/** * Removes a specified fix node from the appropriate list * * @param queue Queue in which to operate * @param fix Fix node to remove * @param type Which list to alter */ static void remove_fix_node( strict_fibonacci_heap *queue, fix_node *fix, int type ) { rank_record *rank = fix->rank; if( queue->fix_list[type] == fix ) { if( fix->right == fix ) queue->fix_list[type] = NULL; else queue->fix_list[type] = fix->right; } if( rank->head[type] == fix ) { if( rank->tail[type] == fix ) { rank->head[type] = NULL; rank->tail[type] = NULL; } else rank->head[type] = fix->right; } else if( rank->tail[type] == fix ) rank->tail[type] = fix->left; fix_node *next = fix->right; fix_node *prev = fix->left; next->left = prev; prev->right = next; check_rank( queue, rank, type ); }
/** * Inserts a fix node into the appropriate list. * * @param queue Queue in which to operate * @param fix Fix node to insert * @param type Which list to alter */ static void insert_fix_node( strict_fibonacci_heap *queue, fix_node *fix, int type ) { rank_record *rank = fix->rank; if( rank->head[type] == NULL ) { rank->head[type] = fix; rank->tail[type] = fix; if( queue->fix_list[type] == NULL ) { fix->right = fix; fix->left = fix; queue->fix_list[type] = fix; return; } else { fix->right = queue->fix_list[type]; fix->left = fix->right->left; fix->right->left = fix; fix->left->right = fix; } } else { fix->right = rank->head[type]; fix->left = fix->right->left; fix->right->left = fix; fix->left->right = fix; if( queue->fix_list[type] == rank->head[type] ) queue->fix_list[type] = fix; rank->head[type] = fix; } check_rank( queue, rank, type ); }
void MetaData::require_valid_entity_rank( EntityRank rank ) const { ThrowRequireMsg(check_rank(rank), "entity_rank " << rank << " >= " << m_entity_rank_names.size() ); }