summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-08-21 11:29:06 +0800
committerPeng Wu <alexepico@gmail.com>2012-08-25 13:28:21 +0800
commitad4e7289182d50ebd7fb040fa180a0c4b54473f6 (patch)
tree3ef22917de2894987ca621b4e78c6a4618d1a6cc
parentde4af396b7c93fa5aaf386afe21e06d0ae053e75 (diff)
downloadlibpinyin-ad4e7289182d50ebd7fb040fa180a0c4b54473f6.tar.gz
libpinyin-ad4e7289182d50ebd7fb040fa180a0c4b54473f6.tar.xz
libpinyin-ad4e7289182d50ebd7fb040fa180a0c4b54473f6.zip
add phrase_large_table2.cpp
-rw-r--r--src/storage/phrase_large_table2.cpp71
-rw-r--r--src/storage/phrase_large_table2.h8
2 files changed, 75 insertions, 4 deletions
diff --git a/src/storage/phrase_large_table2.cpp b/src/storage/phrase_large_table2.cpp
new file mode 100644
index 0000000..b87fb40
--- /dev/null
+++ b/src/storage/phrase_large_table2.cpp
@@ -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;
diff --git a/src/storage/phrase_large_table2.h b/src/storage/phrase_large_table2.h
index 314962c..32f4934 100644
--- a/src/storage/phrase_large_table2.h
+++ b/src/storage/phrase_large_table2.h
@@ -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);
}
};