summaryrefslogtreecommitdiffstats
path: root/src/storage/phrase_large_table2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/storage/phrase_large_table2.cpp')
-rw-r--r--src/storage/phrase_large_table2.cpp35
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);
}