am 66989a86: Merge "Have mPrevWordCount in DicNodeProperties."

* commit '66989a868a615509c2deecdc9e1dfc0a5b8e0cc5':
  Have mPrevWordCount in DicNodeProperties.
main
Keisuke Kuroyanagi 2014-09-16 12:24:53 +00:00 committed by Android Git Automerger
commit bb6521beb1
1 changed files with 11 additions and 6 deletions

View File

@ -32,7 +32,7 @@ class DicNodeProperties {
public: public:
AK_FORCE_INLINE DicNodeProperties() AK_FORCE_INLINE DicNodeProperties()
: mChildrenPtNodeArrayPos(NOT_A_DICT_POS), mDicNodeCodePoint(NOT_A_CODE_POINT), : mChildrenPtNodeArrayPos(NOT_A_DICT_POS), mDicNodeCodePoint(NOT_A_CODE_POINT),
mWordId(NOT_A_WORD_ID), mDepth(0), mLeavingDepth(0) {} mWordId(NOT_A_WORD_ID), mDepth(0), mLeavingDepth(0), mPrevWordCount(0) {}
~DicNodeProperties() {} ~DicNodeProperties() {}
@ -45,6 +45,7 @@ class DicNodeProperties {
mDepth = depth; mDepth = depth;
mLeavingDepth = leavingDepth; mLeavingDepth = leavingDepth;
prevWordIds.copyToArray(&mPrevWordIds, 0 /* offset */); prevWordIds.copyToArray(&mPrevWordIds, 0 /* offset */);
mPrevWordCount = prevWordIds.size();
} }
// Init for root with prevWordsPtNodePos which is used for n-gram // Init for root with prevWordsPtNodePos which is used for n-gram
@ -55,6 +56,7 @@ class DicNodeProperties {
mDepth = 0; mDepth = 0;
mLeavingDepth = 0; mLeavingDepth = 0;
prevWordIds.copyToArray(&mPrevWordIds, 0 /* offset */); prevWordIds.copyToArray(&mPrevWordIds, 0 /* offset */);
mPrevWordCount = prevWordIds.size();
} }
void initByCopy(const DicNodeProperties *const dicNodeProp) { void initByCopy(const DicNodeProperties *const dicNodeProp) {
@ -63,8 +65,9 @@ class DicNodeProperties {
mWordId = dicNodeProp->mWordId; mWordId = dicNodeProp->mWordId;
mDepth = dicNodeProp->mDepth; mDepth = dicNodeProp->mDepth;
mLeavingDepth = dicNodeProp->mLeavingDepth; mLeavingDepth = dicNodeProp->mLeavingDepth;
WordIdArrayView::fromArray(dicNodeProp->mPrevWordIds) const WordIdArrayView prevWordIdArrayView = dicNodeProp->getPrevWordIds();
.copyToArray(&mPrevWordIds, 0 /* offset */); prevWordIdArrayView.copyToArray(&mPrevWordIds, 0 /* offset */);
mPrevWordCount = prevWordIdArrayView.size();
} }
// Init as passing child // Init as passing child
@ -74,8 +77,9 @@ class DicNodeProperties {
mWordId = dicNodeProp->mWordId; mWordId = dicNodeProp->mWordId;
mDepth = dicNodeProp->mDepth + 1; // Increment the depth of a passing child mDepth = dicNodeProp->mDepth + 1; // Increment the depth of a passing child
mLeavingDepth = dicNodeProp->mLeavingDepth; mLeavingDepth = dicNodeProp->mLeavingDepth;
WordIdArrayView::fromArray(dicNodeProp->mPrevWordIds) const WordIdArrayView prevWordIdArrayView = dicNodeProp->getPrevWordIds();
.copyToArray(&mPrevWordIds, 0 /* offset */); prevWordIdArrayView.copyToArray(&mPrevWordIds, 0 /* offset */);
mPrevWordCount = prevWordIdArrayView.size();
} }
int getChildrenPtNodeArrayPos() const { int getChildrenPtNodeArrayPos() const {
@ -104,7 +108,7 @@ class DicNodeProperties {
} }
const WordIdArrayView getPrevWordIds() const { const WordIdArrayView getPrevWordIds() const {
return WordIdArrayView::fromArray(mPrevWordIds); return WordIdArrayView::fromArray(mPrevWordIds).limit(mPrevWordCount);
} }
int getWordId() const { int getWordId() const {
@ -121,6 +125,7 @@ class DicNodeProperties {
uint16_t mDepth; uint16_t mDepth;
uint16_t mLeavingDepth; uint16_t mLeavingDepth;
WordIdArray<MAX_PREV_WORD_COUNT_FOR_N_GRAM> mPrevWordIds; WordIdArray<MAX_PREV_WORD_COUNT_FOR_N_GRAM> mPrevWordIds;
size_t mPrevWordCount;
}; };
} // namespace latinime } // namespace latinime
#endif // LATINIME_DIC_NODE_PROPERTIES_H #endif // LATINIME_DIC_NODE_PROPERTIES_H