File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -28,10 +28,10 @@ public interface PrintableNode {
28
28
* tree root node
29
29
*/
30
30
public static void print (PrintableNode root ) {
31
- List <List <String >> lines = new ArrayList <List < String > >();
31
+ List <List <String >> lines = new ArrayList <>();
32
32
33
- List <PrintableNode > level = new ArrayList <PrintableNode >();
34
- List <PrintableNode > next = new ArrayList <PrintableNode >();
33
+ List <PrintableNode > level = new ArrayList <>();
34
+ List <PrintableNode > next = new ArrayList <>();
35
35
36
36
level .add (root );
37
37
int nn = 1 ;
@@ -86,7 +86,7 @@ public static void print(PrintableNode root) {
86
86
if (line .get (j - 1 ) != null ) {
87
87
c = (line .get (j ) != null ) ? '┴' : '┘' ;
88
88
} else {
89
- if (j < line . size () && line .get (j ) != null ) c = '└' ;
89
+ if (line .get (j ) != null ) c = '└' ;
90
90
}
91
91
}
92
92
System .out .print (c );
@@ -111,9 +111,8 @@ public static void print(PrintableNode root) {
111
111
}
112
112
113
113
// print line of numbers
114
- for (int j = 0 ; j < line . size (); j ++ ) {
114
+ for (String f : line ) {
115
115
116
- String f = line .get (j );
117
116
if (f == null ) f = "" ;
118
117
int gap1 = (int ) Math .ceil (perpiece / 2f - f .length () / 2f );
119
118
int gap2 = (int ) Math .floor (perpiece / 2f - f .length () / 2f );
@@ -132,4 +131,4 @@ public static void print(PrintableNode root) {
132
131
perpiece /= 2 ;
133
132
}
134
133
}
135
- }
134
+ }
You can’t perform that action at this time.
0 commit comments