Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
7389c601
Commit
7389c601
authored
12 years ago
by
Tadashi G. Takaoka
Committed by
Android (Google) Code Review
12 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Add InputPointers.append() method"
parents
e4498929
1087c53f
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/latin/InputPointers.java
+39
-8
39 additions, 8 deletions
java/src/com/android/inputmethod/latin/InputPointers.java
with
39 additions
and
8 deletions
java/src/com/android/inputmethod/latin/InputPointers.java
+
39
−
8
View file @
7389c601
...
...
@@ -18,6 +18,7 @@ package com.android.inputmethod.latin;
import
java.util.Arrays
;
// TODO: Add unit test
public
class
InputPointers
{
private
final
ScalableIntArray
mXCoordinates
=
new
ScalableIntArray
();
private
final
ScalableIntArray
mYCoordinates
=
new
ScalableIntArray
();
...
...
@@ -52,6 +53,25 @@ public class InputPointers {
mTimes
.
copy
(
ip
.
mTimes
);
}
/**
* Append the pointers in the specified {@link InputPointers} to the end of this.
* @param src the source {@link InputPointers} to append the pointers.
* @param startPos the starting index of the pointers in {@code src}.
* @param length the number of pointers to be appended.
*/
public
void
append
(
InputPointers
src
,
int
startPos
,
int
length
)
{
final
int
currentLength
=
getPointerSize
();
final
int
newLength
=
currentLength
+
length
;
mXCoordinates
.
ensureCapacity
(
newLength
);
mYCoordinates
.
ensureCapacity
(
newLength
);
mPointerIds
.
ensureCapacity
(
newLength
);
mTimes
.
ensureCapacity
(
newLength
);
System
.
arraycopy
(
src
.
getXCoordinates
(),
startPos
,
getXCoordinates
(),
currentLength
,
length
);
System
.
arraycopy
(
src
.
getYCoordinates
(),
startPos
,
getYCoordinates
(),
currentLength
,
length
);
System
.
arraycopy
(
src
.
getPointerIds
(),
startPos
,
getPointerIds
(),
currentLength
,
length
);
System
.
arraycopy
(
src
.
getTimes
(),
startPos
,
getTimes
(),
currentLength
,
length
);
}
public
void
reset
()
{
mXCoordinates
.
reset
();
mYCoordinates
.
reset
();
...
...
@@ -64,19 +84,19 @@ public class InputPointers {
}
public
int
[]
getXCoordinates
()
{
return
mXCoordinates
.
m
Array
;
return
mXCoordinates
.
getPrimitive
Array
()
;
}
public
int
[]
getYCoordinates
()
{
return
mYCoordinates
.
m
Array
;
return
mYCoordinates
.
getPrimitive
Array
()
;
}
public
int
[]
getPointerIds
()
{
return
mPointerIds
.
m
Array
;
return
mPointerIds
.
getPrimitive
Array
()
;
}
public
int
[]
getTimes
()
{
return
mTimes
.
m
Array
;
return
mTimes
.
getPrimitive
Array
()
;
}
private
static
class
ScalableIntArray
{
...
...
@@ -98,14 +118,24 @@ public class InputPointers {
}
public
void
add
(
int
val
)
{
if
(
mLength
>=
mArray
.
length
)
{
final
int
[]
newArray
=
new
int
[
mLength
*
2
];
System
.
arraycopy
(
mArray
,
0
,
newArray
,
0
,
mLength
);
}
ensureCapacity
(
mLength
);
mArray
[
mLength
]
=
val
;
++
mLength
;
}
public
void
ensureCapacity
(
int
minimumCapacity
)
{
if
(
mArray
.
length
<
minimumCapacity
)
{
final
int
nextCapacity
=
mArray
.
length
*
2
;
grow
(
minimumCapacity
>
nextCapacity
?
minimumCapacity
:
nextCapacity
);
}
}
private
void
grow
(
int
newCapacity
)
{
final
int
[]
newArray
=
new
int
[
newCapacity
];
System
.
arraycopy
(
mArray
,
0
,
newArray
,
0
,
mLength
);
mArray
=
newArray
;
}
public
int
getLength
()
{
return
mLength
;
}
...
...
@@ -121,6 +151,7 @@ public class InputPointers {
public
void
copy
(
ScalableIntArray
ip
)
{
mArray
=
Arrays
.
copyOf
(
ip
.
mArray
,
ip
.
mArray
.
length
);
mLength
=
ip
.
mLength
;
}
public
void
set
(
ScalableIntArray
ip
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment