aboutsummaryrefslogtreecommitdiffstats
path: root/native/src/words_priority_queue_pool.h
diff options
context:
space:
mode:
authorsatok <satok@google.com>2012-01-26 00:38:53 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-01-26 00:38:53 -0800
commit13c66f201767238f59ba90a88f682c108242755f (patch)
treeaea930398603260cc970a44a56eec52b91aad93b /native/src/words_priority_queue_pool.h
parent4bea2e7613a8005b599fcd1deda94600227d637a (diff)
parent6a03350521cb1ce65dd17db8fe4a4e8cb40468cb (diff)
downloadlatinime-13c66f201767238f59ba90a88f682c108242755f.tar.gz
latinime-13c66f201767238f59ba90a88f682c108242755f.tar.xz
latinime-13c66f201767238f59ba90a88f682c108242755f.zip
am 6a033505: Merge "Refactor words priority queue"
* commit '6a03350521cb1ce65dd17db8fe4a4e8cb40468cb': Refactor words priority queue
Diffstat (limited to 'native/src/words_priority_queue_pool.h')
-rw-r--r--native/src/words_priority_queue_pool.h37
1 files changed, 17 insertions, 20 deletions
diff --git a/native/src/words_priority_queue_pool.h b/native/src/words_priority_queue_pool.h
index 599b89711..a4aa8b6ca 100644
--- a/native/src/words_priority_queue_pool.h
+++ b/native/src/words_priority_queue_pool.h
@@ -43,25 +43,24 @@ class WordsPriorityQueuePool {
return mMasterQueue;
}
- // TODO: Come up with more generic pool
- WordsPriorityQueue* getSubQueue1(const int id) {
- if (id < 0 || id >= SUB_QUEUE_MAX_COUNT) {
- if (DEBUG_WORDS_PRIORITY_QUEUE) {
- assert(false);
- }
+ WordsPriorityQueue* getSubQueue(const int wordIndex, const int inputWordLength) {
+ if (wordIndex > SUB_QUEUE_MAX_WORD_INDEX) {
return 0;
}
- return mSubQueues1[id];
- }
-
- WordsPriorityQueue* getSubQueue2(const int id) {
- if (id < 0 || id >= SUB_QUEUE_MAX_COUNT) {
+ if (inputWordLength < 0 || inputWordLength >= SUB_QUEUE_MAX_COUNT) {
if (DEBUG_WORDS_PRIORITY_QUEUE) {
assert(false);
}
return 0;
}
- return mSubQueues2[id];
+ // TODO: Come up with more generic pool
+ if (wordIndex == 1) {
+ return mSubQueues1[inputWordLength];
+ } else if (wordIndex == 2) {
+ return mSubQueues2[inputWordLength];
+ } else {
+ return 0;
+ }
}
inline void clearAll() {
@@ -72,15 +71,13 @@ class WordsPriorityQueuePool {
}
}
- inline void clearSubQueue1() {
+ inline void clearSubQueue(const int wordIndex) {
for (int i = 0; i < SUB_QUEUE_MAX_COUNT; ++i) {
- mSubQueues1[i]->clear();
- }
- }
-
- inline void clearSubQueue2() {
- for (int i = 0; i < SUB_QUEUE_MAX_COUNT; ++i) {
- mSubQueues2[i]->clear();
+ if (wordIndex == 1) {
+ mSubQueues1[i]->clear();
+ } else if (wordIndex == 2) {
+ mSubQueues2[i]->clear();
+ }
}
}