Skip to content

Commit 1a77591

Browse files
committed
158 (1) update variable name
1 parent 9b1793f commit 1a77591

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/_158_ReadNCharactersGivenRead4II/Solution.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,29 @@
3030
*/
3131
public class Solution extends Reader4 {
3232

33-
private char[] buffer = new char[4];
33+
// unread part from last read4 call
34+
private char[] cache = new char[4];
3435
private int offset = 0;
3536
private int bufsize = 0;
3637

3738
/**
38-
* Reads from buffer first and then use read4 to read more content.
39+
* Reads from cache first and then use read4 to read more content.
3940
*
40-
* @param buf Destination buffer
41+
* @param buf Destination cache
4142
* @param n Maximum number of characters to read
4243
* @return The number of characters read
4344
*/
4445
public int read(char[] buf, int n) {
4546
int readBytes = 0;
4647
boolean eof = false;
4748
while (!eof && readBytes < n) {
48-
int size = (bufsize > 0) ? bufsize : read4(buffer);
49+
int size = (bufsize > 0) ? bufsize : read4(cache);
4950
if (bufsize == 0 && size < 4) {
5051
eof = true;
5152
}
5253
int bytes = Math.min(n - readBytes, size);
5354
for (int i = 0; i < bytes; i++) {
54-
buf[readBytes + i] = buffer[offset + i];
55+
buf[readBytes + i] = cache[offset + i];
5556
}
5657
offset = (offset + bytes) % 4;
5758
bufsize = size - bytes;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy