diff options
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(); + } } } |