File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed
src/main/java/edu/princeton/cs/algs4 Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -60,10 +60,10 @@ public int size() {
60
60
// resize the underlying array holding the elements
61
61
private void resize (int capacity ) {
62
62
assert capacity >= n ;
63
- Item [] temp = (Item []) new Object [capacity ];
63
+ Item [] copy = (Item []) new Object [capacity ];
64
64
for (int i = 0 ; i < n ; i ++)
65
- temp [i ] = a [i ];
66
- a = temp ;
65
+ copy [i ] = a [i ];
66
+ a = copy ;
67
67
}
68
68
69
69
/**
Original file line number Diff line number Diff line change @@ -72,11 +72,11 @@ public int size() {
72
72
// resize the underlying array
73
73
private void resize (int capacity ) {
74
74
assert capacity >= n ;
75
- Item [] temp = (Item []) new Object [capacity ];
75
+ Item [] copy = (Item []) new Object [capacity ];
76
76
for (int i = 0 ; i < n ; i ++) {
77
- temp [i ] = q [(first + i ) % q .length ];
77
+ copy [i ] = q [(first + i ) % q .length ];
78
78
}
79
- q = temp ;
79
+ q = copy ;
80
80
first = 0 ;
81
81
last = n ;
82
82
}
Original file line number Diff line number Diff line change @@ -74,11 +74,11 @@ private void resize(int capacity) {
74
74
assert capacity >= n ;
75
75
76
76
// textbook implementation
77
- Item [] temp = (Item []) new Object [capacity ];
77
+ Item [] copy = (Item []) new Object [capacity ];
78
78
for (int i = 0 ; i < n ; i ++) {
79
- temp [i ] = a [i ];
79
+ copy [i ] = a [i ];
80
80
}
81
- a = temp ;
81
+ a = copy ;
82
82
83
83
// alternative implementation
84
84
// a = java.util.Arrays.copyOf(a, capacity);
You can’t perform that action at this time.
0 commit comments