add phrase_large_table2.cpp
authorPeng Wu <alexepico@gmail.com>
Tue, 21 Aug 2012 03:29:06 +0000 (11:29 +0800)
committerPeng Wu <alexepico@gmail.com>
Sat, 25 Aug 2012 05:28:21 +0000 (13:28 +0800)
src/storage/phrase_large_table2.cpp [new file with mode: 0644]
src/storage/phrase_large_table2.h

diff --git a/src/storage/phrase_large_table2.cpp b/src/storage/phrase_large_table2.cpp
new file mode 100644 (file)
index 0000000..b87fb40
--- /dev/null
@@ -0,0 +1,71 @@
+/* 
+ *  libpinyin
+ *  Library to deal with pinyin.
+ *  
+ *  Copyright (C) 2012 Peng Wu <alexepico@gmail.com>
+ *  
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ * 
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+
+#include <assert.h>
+#include <string.h>
+#include "phrase_large_table2.h"
+
+
+/* class definition */
+
+namespace pinyin{
+
+class PhraseLengthIndexLevel2{
+protected:
+    GArray * m_phrase_array_indexes;
+public:
+    PhraseLengthIndexLevel2();
+    ~PhraseLengthIndexLevel2();
+
+    /* load/store method */
+    bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end);
+    bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end);
+
+    /* search method */
+    int search(int phrase_length, /* in */ ucs4_t phrase[],
+               /* out */ PhraseTokens tokens);
+
+    /* add_index/remove_index method */
+    int add_index(int phrase_length, /* in */ ucs4_t phrase[],
+                  /* in */ phrase_token_t token);
+    int remove_index(int phrase_length, /* in */ ucs4_t phrase[],
+                     /* in */ phrase_token_t token);
+};
+
+template<size_t phrase_length>
+class PhraseArrayIndexLevel{
+protected:
+    MemoryChunk m_chunk;
+public:
+    bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end);
+    bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end);
+
+    /* search method */
+    int search(/* in */ ucs4_t phrase[], /* out */ PhraseTokens tokens);
+
+    /* add_index/remove_index method */
+    int add_index(/* in */ ucs4_t phrase[], /* in */ phrase_token_t token);
+    int remove_index(/* in */ ucs4_t phrase[], /* in */ phrase_token_t token);
+};
+
+};
+
+using namespace pinyin;
index 314962c..32f4934 100644 (file)
@@ -45,7 +45,7 @@ public:
 
     /* load/store method */
     bool load(MemoryChunk * chunk, table_offset_t offset, table_offset_t end);
-    bool store(MemoryChunk * newchunk, table_offset_t offset, table_offset_t & end);
+    bool store(MemoryChunk * new_chunk, table_offset_t offset, table_offset_t & end);
 
     /* search method */
     int search(int phrase_length, /* in */ ucs4_t phrase[],
@@ -85,9 +85,9 @@ public:
         return m_bitmap_table.load(chunk, 0, chunk->size());
     }
 
-    bool store(MemoryChunk * newchunk){
+    bool store(MemoryChunk * new_chunk){
         table_offset_t end;
-        return m_bitmap_table.store(newchunk, 0, end);
+        return m_bitmap_table.store(new_chunk, 0, end);
     }
 
     bool load_text(FILE * file);
@@ -103,7 +103,7 @@ public:
         return m_bitmap_table.add_index(phrase_length, phrase, token);
     }
 
-    int remove_index(int phrase_length, /* in */ ucs4_t phrase[], /* out */ phrase_token_t token) {
+    int remove_index(int phrase_length, /* in */ ucs4_t phrase[], /* in */ phrase_token_t token) {
         return m_bitmap_table.remove_index(phrase_length, phrase, token);
     }
 };