| 133 | } |
| 134 | |
| 135 | void OpenQueue::Update( PathNode* pNode ) |
| 136 | { |
| 137 | #ifdef DEBUG_PATH_DEEP |
| 138 | printf( "Open Update: " ); |
| 139 | graph->PrintStateInfo( pNode->state ); |
| 140 | printf( " total=%.1f\n", pNode->totalCost ); |
| 141 | #endif |
| 142 | |
| 143 | MPASSERT( pNode->inOpen ); |
| 144 | |
| 145 | // If the node now cost less than the one before it, |
| 146 | // move it to the front of the list. |
| 147 | if ( pNode->prev != sentinel && pNode->totalCost < pNode->prev->totalCost ) { |
| 148 | pNode->Unlink(); |
| 149 | sentinel->next->AddBefore( pNode ); |
| 150 | } |
| 151 | |
| 152 | // If the node is too high, move to the right. |
| 153 | if ( pNode->totalCost > pNode->next->totalCost ) { |
| 154 | PathNode* it = pNode->next; |
| 155 | pNode->Unlink(); |
| 156 | |
| 157 | while ( pNode->totalCost > it->totalCost ) |
| 158 | it = it->next; |
| 159 | |
| 160 | it->AddBefore( pNode ); |
| 161 | #ifdef DEBUG |
| 162 | sentinel->CheckList(); |
| 163 | #endif |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | |
| 168 | class ClosedSet |
no test coverage detected