| 671 | } |
| 672 | |
| 673 | func (n *SweepNode) print(w io.Writer, prefix string, cmp int) { |
| 674 | c := "" |
| 675 | if cmp < 0 { |
| 676 | c = "│ " |
| 677 | } else if 0 < cmp { |
| 678 | c = " " |
| 679 | } |
| 680 | if n.right != nil { |
| 681 | n.right.print(w, prefix+c, 1) |
| 682 | } else if n.left != nil { |
| 683 | fmt.Fprintf(w, "%v%v┌─nil\n", prefix, c) |
| 684 | } |
| 685 | |
| 686 | c = "" |
| 687 | if 0 < cmp { |
| 688 | c = "┌─" |
| 689 | } else if cmp < 0 { |
| 690 | c = "└─" |
| 691 | } |
| 692 | fmt.Fprintf(w, "%v%v%v\n", prefix, c, n.SweepPoint) |
| 693 | |
| 694 | c = "" |
| 695 | if 0 < cmp { |
| 696 | c = "│ " |
| 697 | } else if cmp < 0 { |
| 698 | c = " " |
| 699 | } |
| 700 | if n.left != nil { |
| 701 | n.left.print(w, prefix+c, -1) |
| 702 | } else if n.right != nil { |
| 703 | fmt.Fprintf(w, "%v%v└─nil\n", prefix, c) |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | func (n *SweepNode) Print(w io.Writer) { |
| 708 | n.print(w, "", 0) |