From 0b35cb6786587dc9d0a442f1cd0267d13d1f19c2 Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Mon, 27 Aug 2012 10:59:32 +0800 Subject: [PATCH] rename PhraseIndexItem to PhraseIndexItem2 --- src/storage/phrase_large_table2.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/storage/phrase_large_table2.cpp b/src/storage/phrase_large_table2.cpp index cccb0c8..ad9c2bb 100644 --- a/src/storage/phrase_large_table2.cpp +++ b/src/storage/phrase_large_table2.cpp @@ -50,9 +50,25 @@ public: /* in */ phrase_token_t token); }; + +template +struct PhraseIndexItem2{ + phrase_token_t m_token; + ucs4_t m_phrase[phrase_length]; +public: + PhraseIndexItem2(ucs4_t phrase[], phrase_token_t token){ + memmove(m_phrase, phrase, sizeof(ucs4_t) * phrase_length); + m_token = token; + } +}; + + template class PhraseArrayIndexLevel2{ protected: + typedef PhraseIndexItem2 IndexItem; + +protected: MemoryChunk m_chunk; public: bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end); @@ -73,19 +89,8 @@ using namespace pinyin; /* class implementation */ template -struct PhraseIndexItem{ - phrase_token_t m_token; - ucs4_t m_phrase[phrase_length]; -public: - PhraseIndexItem(ucs4_t phrase[], phrase_token_t token){ - memmove(m_phrase, phrase, sizeof(ucs4_t) * phrase_length); - m_token = token; - } -}; - -template -static int phrase_compare(const PhraseIndexItem &lhs, - const PhraseIndexItem &rhs){ +static int phrase_compare(const PhraseIndexItem2 &lhs, + const PhraseIndexItem2 &rhs){ ucs4_t * phrase_lhs = (ucs4_t *) lhs.m_phrase; ucs4_t * phrase_rhs = (ucs4_t *) rhs.m_phrase; @@ -93,7 +98,7 @@ static int phrase_compare(const PhraseIndexItem &lhs, } template -static bool phrase_less_than(const PhraseIndexItem & lhs, - const PhraseIndexItem & rhs){ +static bool phrase_less_than(const PhraseIndexItem2 & lhs, + const PhraseIndexItem2 & rhs){ return 0 > phrase_compare(lhs, rhs); } -- 2.7.4