Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b90333af
authored
Jan 23, 2022
by
Dustin
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Clean up UnboundedIntArray
parent
3daa74dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/UnboundedIntArray.java
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/UnboundedIntArrayTest.java
library/extractor/src/main/java/com/google/android/exoplayer2/extractor/avi/UnboundedIntArray.java
View file @
b90333af
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
package
com
.
google
.
android
.
exoplayer2
.
extractor
.
avi
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.VisibleForTesting
;
import
java.util.Arrays
;
import
java.util.Arrays
;
public
class
UnboundedIntArray
{
public
class
UnboundedIntArray
{
@NonNull
@NonNull
@VisibleForTesting
int
[]
array
;
int
[]
array
;
//unint
//unint
int
size
=
0
;
private
int
size
=
0
;
public
UnboundedIntArray
()
{
public
UnboundedIntArray
()
{
this
(
8
);
this
(
8
);
...
@@ -32,7 +34,9 @@ public class UnboundedIntArray {
...
@@ -32,7 +34,9 @@ public class UnboundedIntArray {
}
}
public
void
pack
()
{
public
void
pack
()
{
array
=
Arrays
.
copyOf
(
array
,
size
);
if
(
size
!=
array
.
length
)
{
array
=
Arrays
.
copyOf
(
array
,
size
);
}
}
}
protected
void
grow
()
{
protected
void
grow
()
{
...
@@ -40,6 +44,11 @@ public class UnboundedIntArray {
...
@@ -40,6 +44,11 @@ public class UnboundedIntArray {
array
=
Arrays
.
copyOf
(
array
,
increase
+
array
.
length
+
size
);
array
=
Arrays
.
copyOf
(
array
,
increase
+
array
.
length
+
size
);
}
}
public
int
[]
getArray
()
{
pack
();
return
array
;
}
/**
/**
* Only works if values are in sequential order
* Only works if values are in sequential order
* @param v
* @param v
...
...
library/extractor/src/test/java/com/google/android/exoplayer2/extractor/avi/UnboundedIntArrayTest.java
View file @
b90333af
...
@@ -9,7 +9,7 @@ public class UnboundedIntArrayTest {
...
@@ -9,7 +9,7 @@ public class UnboundedIntArrayTest {
final
UnboundedIntArray
unboundedIntArray
=
new
UnboundedIntArray
();
final
UnboundedIntArray
unboundedIntArray
=
new
UnboundedIntArray
();
unboundedIntArray
.
add
(
4
);
unboundedIntArray
.
add
(
4
);
Assert
.
assertEquals
(
1
,
unboundedIntArray
.
getSize
());
Assert
.
assertEquals
(
1
,
unboundedIntArray
.
getSize
());
Assert
.
assertEquals
(
unboundedIntArray
.
array
[
0
],
4
);
Assert
.
assertEquals
(
unboundedIntArray
.
getArray
()
[
0
],
4
);
}
}
@Test
@Test
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment