diff options
author | Peng Wu <alexepico@gmail.com> | 2012-08-27 10:59:32 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-08-27 10:59:32 +0800 |
commit | 0b35cb6786587dc9d0a442f1cd0267d13d1f19c2 (patch) | |
tree | 993bfe573f9ad298c65b16f9e5b6ab024f985003 /src/storage/phrase_large_table2.cpp | |
parent | 993983933976cb2a864eb155b952deded9e20784 (diff) | |
download | libpinyin-0b35cb6786587dc9d0a442f1cd0267d13d1f19c2.tar.gz libpinyin-0b35cb6786587dc9d0a442f1cd0267d13d1f19c2.tar.xz libpinyin-0b35cb6786587dc9d0a442f1cd0267d13d1f19c2.zip |
rename PhraseIndexItem to PhraseIndexItem2
Diffstat (limited to 'src/storage/phrase_large_table2.cpp')
-rw-r--r-- | src/storage/phrase_large_table2.cpp | 35 |
1 files 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<size_t phrase_length> +struct PhraseIndexItem2{ + phrase_token_t m_token; + ucs4_t m_phrase[phrase_length]; +public: + PhraseIndexItem2<phrase_length>(ucs4_t phrase[], phrase_token_t token){ + memmove(m_phrase, phrase, sizeof(ucs4_t) * phrase_length); + m_token = token; + } +}; + + template<size_t phrase_length> class PhraseArrayIndexLevel2{ protected: + typedef PhraseIndexItem2<phrase_length> 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<size_t phrase_length> -struct PhraseIndexItem{ - phrase_token_t m_token; - ucs4_t m_phrase[phrase_length]; -public: - PhraseIndexItem<phrase_length>(ucs4_t phrase[], phrase_token_t token){ - memmove(m_phrase, phrase, sizeof(ucs4_t) * phrase_length); - m_token = token; - } -}; - -template<size_t phrase_length> -static int phrase_compare(const PhraseIndexItem<phrase_length> &lhs, - const PhraseIndexItem<phrase_length> &rhs){ +static int phrase_compare(const PhraseIndexItem2<phrase_length> &lhs, + const PhraseIndexItem2<phrase_length> &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<phrase_length> &lhs, } template<size_t phrase_length> -static bool phrase_less_than(const PhraseIndexItem<phrase_length> & lhs, - const PhraseIndexItem<phrase_length> & rhs){ +static bool phrase_less_than(const PhraseIndexItem2<phrase_length> & lhs, + const PhraseIndexItem2<phrase_length> & rhs){ return 0 > phrase_compare(lhs, rhs); } |