| 432 | } |
| 433 | |
| 434 | public Path<T> first() { |
| 435 | if (root == NullNode) return null; |
| 436 | |
| 437 | Node<T> newRoot = new Node(root); |
| 438 | Cell<Node<T>> ancestors = null; |
| 439 | |
| 440 | Node<T> old = root; |
| 441 | Node<T> new_ = newRoot; |
| 442 | while (old.left != NullNode) { |
| 443 | ancestors = new Cell(new_, ancestors); |
| 444 | |
| 445 | old = old.left; |
| 446 | new_ = new_.left = new Node(old); |
| 447 | } |
| 448 | |
| 449 | return new Path(true, new_, |
| 450 | new PersistentSet(newRoot, comparator, size), |
| 451 | ancestors); |
| 452 | } |
| 453 | |
| 454 | public Path<T> last() { |
| 455 | if (root == NullNode) return null; |