Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1a77591

Browse files
committed
158 (1) update variable name
1 parent9b1793f commit1a77591

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
publicclassSolutionextendsReader4 {
3232

33-
privatechar[]buffer =newchar[4];
33+
// unread part from last read4 call
34+
privatechar[]cache =newchar[4];
3435
privateintoffset =0;
3536
privateintbufsize =0;
3637

3738
/**
38-
* Reads frombuffer first and then use read4 to read more content.
39+
* Reads fromcache first and then use read4 to read more content.
3940
*
40-
* @param buf Destinationbuffer
41+
* @param buf Destinationcache
4142
* @param n Maximum number of characters to read
4243
* @return The number of characters read
4344
*/
4445
publicintread(char[]buf,intn) {
4546
intreadBytes =0;
4647
booleaneof =false;
4748
while (!eof &&readBytes <n) {
48-
intsize = (bufsize >0) ?bufsize :read4(buffer);
49+
intsize = (bufsize >0) ?bufsize :read4(cache);
4950
if (bufsize ==0 &&size <4) {
5051
eof =true;
5152
}
5253
intbytes =Math.min(n -readBytes,size);
5354
for (inti =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)

[8]ページ先頭

©2009-2025 Movatter.jp