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
655b65cb
Commit
655b65cb
authored
11 years ago
by
Keisuke Kuroyanagi
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup DicNodePriorityQueue.
Change-Id: Ia44ca0e14f8aad090ae2b8007771dea6d9b41221
parent
144b9a63
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
native/jni/src/suggest/core/dicnode/dic_node_priority_queue.h
+12
-11
12 additions, 11 deletions
...ve/jni/src/suggest/core/dicnode/dic_node_priority_queue.h
with
12 additions
and
11 deletions
native/jni/src/suggest/core/dicnode/dic_node_priority_queue.h
+
12
−
11
View file @
655b65cb
...
@@ -70,13 +70,13 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
...
@@ -70,13 +70,13 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
for
(
int
i
=
0
;
i
<
mCapacity
+
1
;
++
i
)
{
for
(
int
i
=
0
;
i
<
mCapacity
+
1
;
++
i
)
{
mDicNodesBuf
[
i
].
finalize
();
mDicNodesBuf
[
i
].
finalize
();
mDicNodesBuf
[
i
].
setReleaseListener
(
this
);
mDicNodesBuf
[
i
].
setReleaseListener
(
this
);
mUnusedNodeIndices
[
i
]
=
i
==
mCapacity
?
NOT_A_NODE_ID
:
static_cast
<
int
>
(
i
)
+
1
;
mUnusedNodeIndices
[
i
]
=
(
i
==
mCapacity
)
?
NOT_A_NODE_ID
:
(
i
+
1
)
;
}
}
mNextUnusedNodeId
=
0
;
mNextUnusedNodeId
=
0
;
}
}
// Copy
// Copy
AK_FORCE_INLINE
DicNode
*
copyPush
(
DicNode
*
dicNode
)
{
AK_FORCE_INLINE
DicNode
*
copyPush
(
const
DicNode
*
const
dicNode
)
{
return
copyPush
(
dicNode
,
mMaxSize
);
return
copyPush
(
dicNode
,
mMaxSize
);
}
}
...
@@ -118,7 +118,8 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
...
@@ -118,7 +118,8 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
DISALLOW_IMPLICIT_CONSTRUCTORS
(
DicNodePriorityQueue
);
DISALLOW_IMPLICIT_CONSTRUCTORS
(
DicNodePriorityQueue
);
static
const
int
NOT_A_NODE_ID
=
-
1
;
static
const
int
NOT_A_NODE_ID
=
-
1
;
AK_FORCE_INLINE
static
bool
compareDicNode
(
DicNode
*
left
,
DicNode
*
right
)
{
AK_FORCE_INLINE
static
bool
compareDicNode
(
const
DicNode
*
const
left
,
const
DicNode
*
const
right
)
{
return
left
->
compare
(
right
);
return
left
->
compare
(
right
);
}
}
...
@@ -141,10 +142,10 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
...
@@ -141,10 +142,10 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
}
}
AK_FORCE_INLINE
void
pop
()
{
AK_FORCE_INLINE
void
pop
()
{
copyPop
(
0
);
copyPop
(
nullptr
);
}
}
AK_FORCE_INLINE
bool
betterThanWorstDicNode
(
DicNode
*
dicNode
)
const
{
AK_FORCE_INLINE
bool
betterThanWorstDicNode
(
const
DicNode
*
const
dicNode
)
const
{
DicNode
*
worstNode
=
mDicNodesQueue
.
top
();
DicNode
*
worstNode
=
mDicNodesQueue
.
top
();
if
(
!
worstNode
)
{
if
(
!
worstNode
)
{
return
true
;
return
true
;
...
@@ -154,7 +155,7 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
...
@@ -154,7 +155,7 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
AK_FORCE_INLINE
DicNode
*
searchEmptyDicNode
()
{
AK_FORCE_INLINE
DicNode
*
searchEmptyDicNode
()
{
if
(
mCapacity
==
0
)
{
if
(
mCapacity
==
0
)
{
return
0
;
return
nullptr
;
}
}
if
(
mNextUnusedNodeId
==
NOT_A_NODE_ID
)
{
if
(
mNextUnusedNodeId
==
NOT_A_NODE_ID
)
{
AKLOGI
(
"No unused node found."
);
AKLOGI
(
"No unused node found."
);
...
@@ -163,7 +164,7 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
...
@@ -163,7 +164,7 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
i
,
mDicNodesBuf
[
i
].
isUsed
(),
mUnusedNodeIndices
[
i
]);
i
,
mDicNodesBuf
[
i
].
isUsed
(),
mUnusedNodeIndices
[
i
]);
}
}
ASSERT
(
false
);
ASSERT
(
false
);
return
0
;
return
nullptr
;
}
}
DicNode
*
dicNode
=
&
mDicNodesBuf
[
mNextUnusedNodeId
];
DicNode
*
dicNode
=
&
mDicNodesBuf
[
mNextUnusedNodeId
];
markNodeAsUsed
(
dicNode
);
markNodeAsUsed
(
dicNode
);
...
@@ -179,7 +180,7 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
...
@@ -179,7 +180,7 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
AK_FORCE_INLINE
DicNode
*
pushPoolNodeWithMaxSize
(
DicNode
*
dicNode
,
const
int
maxSize
)
{
AK_FORCE_INLINE
DicNode
*
pushPoolNodeWithMaxSize
(
DicNode
*
dicNode
,
const
int
maxSize
)
{
if
(
!
dicNode
)
{
if
(
!
dicNode
)
{
return
0
;
return
nullptr
;
}
}
if
(
!
isFull
(
maxSize
))
{
if
(
!
isFull
(
maxSize
))
{
mDicNodesQueue
.
push
(
dicNode
);
mDicNodesQueue
.
push
(
dicNode
);
...
@@ -191,15 +192,15 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
...
@@ -191,15 +192,15 @@ class DicNodePriorityQueue : public DicNodeReleaseListener {
return
dicNode
;
return
dicNode
;
}
}
dicNode
->
finalize
();
dicNode
->
finalize
();
return
0
;
return
nullptr
;
}
}
// Copy
// Copy
AK_FORCE_INLINE
DicNode
*
copyPush
(
DicNode
*
dicNode
,
const
int
maxSize
)
{
AK_FORCE_INLINE
DicNode
*
copyPush
(
const
DicNode
*
const
dicNode
,
const
int
maxSize
)
{
return
pushPoolNodeWithMaxSize
(
newDicNode
(
dicNode
),
maxSize
);
return
pushPoolNodeWithMaxSize
(
newDicNode
(
dicNode
),
maxSize
);
}
}
AK_FORCE_INLINE
DicNode
*
newDicNode
(
DicNode
*
dicNode
)
{
AK_FORCE_INLINE
DicNode
*
newDicNode
(
const
DicNode
*
const
dicNode
)
{
DicNode
*
newNode
=
searchEmptyDicNode
();
DicNode
*
newNode
=
searchEmptyDicNode
();
if
(
newNode
)
{
if
(
newNode
)
{
DicNodeUtils
::
initByCopy
(
dicNode
,
newNode
);
DicNodeUtils
::
initByCopy
(
dicNode
,
newNode
);
...
...
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