FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java/src/main/java/com/jsoniter/Slice.java at master · androiddream/java · GitHub
androiddream
/
java
Public
forked from
json-iterator/java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
Slice.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
66 lines (52 loc) · 1.47 KB
Breadcrumbs
java
/
src
/
main
/
java
/
com
/
jsoniter
/
Slice.java
Copy path
File metadata and controls
66 lines (52 loc) · 1.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package
com
.
jsoniter
;
public
class
Slice
{
public
byte
[]
data
;
public
int
head
;
public
int
len
;
public
Slice
(
byte
[]
data
,
int
head
,
int
len
) {
this
.
data
=
data
;
this
.
head
=
head
;
this
.
len
=
len
;
}
public
static
Slice
make
(
int
len
,
int
cap
) {
return
new
Slice
(
new
byte
[
cap
],
0
,
len
);
}
public
static
Slice
make
(
String
str
) {
byte
[]
data
=
str
.
getBytes
();
return
new
Slice
(
data
,
0
,
data
.
length
);
}
public
final
void
append
(
byte
c
) {
if
(
len
==
data
.
length
) {
byte
[]
newData
=
new
byte
[
data
.
length
*
2
];
System
.
arraycopy
(
data
,
0
,
newData
,
0
,
data
.
length
);
data
=
newData
;
}
data
[
len
++] =
c
;
}
public
final
byte
at
(
int
pos
) {
return
data
[
head
+
pos
];
}
@
Override
public
final
boolean
equals
(
Object
o
) {
if
(
this
==
o
)
return
true
;
if
(
o
==
null
||
getClass
() !=
o
.
getClass
())
return
false
;
Slice
slice
= (
Slice
)
o
;
if
(
len
!=
slice
.
len
)
return
false
;
for
(
int
i
=
head
;
i
<
len
;
i
++)
if
(
data
[
i
] !=
slice
.
data
[
i
])
return
false
;
return
true
;
}
@
Override
public
final
int
hashCode
() {
int
result
=
1
;
for
(
int
i
=
head
;
i
<
len
;
i
++) {
result
=
31
*
result
+
data
[
i
];
}
return
result
;
}
@
Override
public
final
String
toString
() {
return
new
String
(
data
,
head
,
len
);
}
}
Back
|
FazBrowse Home
|
New Git URL