Disconnects the given node from the list it is currently in. @param @param a the node to disconnect from its current list @return a node in the list that 'a' was originally apart of. Returns null if a was its own list (ie: a list of size 1, or no "list").
(FibNode<T> a)
| 357 | * {@code null} if a was its own list (ie: a list of size 1, or no "list"). |
| 358 | */ |
| 359 | private static <T> FibNode<T> delink(FibNode<T> a) |
| 360 | { |
| 361 | if(a.left == a)//a is on its own, nothing to return |
| 362 | return null; |
| 363 | //else, a is in a list |
| 364 | |
| 365 | FibNode<T> a_left_orig = a.left;//link to the rest of the list that we can return |
| 366 | |
| 367 | a.left.right = a.right; |
| 368 | a.right.left = a_left_orig; |
| 369 | //a no longer is in its original list, return link |
| 370 | |
| 371 | //fix a's links to point to itself not that it has been de-linked from everyone else |
| 372 | a.left = a.right = a; |
| 373 | |
| 374 | return a_left_orig; |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Merges the two lists given by the two nodes. Works if either node represents a list of size 1 / is on its own. The node with the smaller value will be returned. |
no outgoing calls
no test coverage detected