| 129 | } |
| 130 | |
| 131 | bool Push(int i, int j, float T) |
| 132 | { |
| 133 | HeapElem *tmp = empty, *add = empty; |
| 134 | if (empty == tail) |
| 135 | return false; |
| 136 | while (tmp->prev->T > T) tmp = tmp->prev; |
| 137 | if (tmp != empty) |
| 138 | { |
| 139 | add->prev->next = add->next; |
| 140 | add->next->prev = add->prev; |
| 141 | empty = add->next; |
| 142 | add->prev = tmp->prev; |
| 143 | add->next = tmp; |
| 144 | add->prev->next = add; |
| 145 | add->next->prev = add; |
| 146 | } |
| 147 | else |
| 148 | { |
| 149 | empty = empty->next; |
| 150 | } |
| 151 | add->i = i; |
| 152 | add->j = j; |
| 153 | add->T = T; |
| 154 | in++; |
| 155 | return true; |
| 156 | } |
| 157 | |
| 158 | bool Pop(int *i, int *j) |
| 159 | { |