| 1278 | typename mem_manager |
| 1279 | > |
| 1280 | bool sequence_kernel_1<T,mem_manager>:: |
| 1281 | keep_node_balanced ( |
| 1282 | node*& t |
| 1283 | ) |
| 1284 | { |
| 1285 | // make a reference to the current node so we don't have to dereference |
| 1286 | // a pointer a bunch of times |
| 1287 | node& tree = *t; |
| 1288 | |
| 1289 | // if tree does not need to be balanced then return false |
| 1290 | if (tree.balance == 0) |
| 1291 | return false; |
| 1292 | |
| 1293 | |
| 1294 | // if tree needs to be rotated left |
| 1295 | if (tree.balance == 2) |
| 1296 | { |
| 1297 | if (tree.right->balance >= 0) |
| 1298 | rotate_left(t); |
| 1299 | else |
| 1300 | double_rotate_left(t); |
| 1301 | } |
| 1302 | // else if the tree needs to be rotated right |
| 1303 | else if (tree.balance == -2) |
| 1304 | { |
| 1305 | if (tree.left->balance <= 0) |
| 1306 | rotate_right(t); |
| 1307 | else |
| 1308 | double_rotate_right(t); |
| 1309 | } |
| 1310 | |
| 1311 | |
| 1312 | if (t->balance == 0) |
| 1313 | return true; |
| 1314 | else |
| 1315 | return false; |
| 1316 | } |
| 1317 | |
| 1318 | // ---------------------------------------------------------------------------------------- |
| 1319 |
nothing calls this directly
no test coverage detected