diff options
author | 2012-01-26 16:13:25 +0900 | |
---|---|---|
committer | 2012-01-26 16:13:25 +0900 | |
commit | 7409d151a18e64450f40e9d798fb3d28ef4a4d76 (patch) | |
tree | 498da9bd1b4fb0679094f01077f29b21f9324d48 /native/src/words_priority_queue_pool.h | |
parent | f8ce19c29de6440e15a16d91a86e0e6d840d114c (diff) | |
download | latinime-7409d151a18e64450f40e9d798fb3d28ef4a4d76.tar.gz latinime-7409d151a18e64450f40e9d798fb3d28ef4a4d76.tar.xz latinime-7409d151a18e64450f40e9d798fb3d28ef4a4d76.zip |
Refactor words priority queue
Change-Id: I14b7ef39263ad2b1d5ec087bc80b7b8d7c30abe7
Diffstat (limited to 'native/src/words_priority_queue_pool.h')
-rw-r--r-- | native/src/words_priority_queue_pool.h | 37 |
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(); + } } } |