diff options
author | Peng Wu <alexepico@gmail.com> | 2012-08-21 11:29:06 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2012-08-25 13:28:21 +0800 |
commit | ad4e7289182d50ebd7fb040fa180a0c4b54473f6 (patch) | |
tree | 3ef22917de2894987ca621b4e78c6a4618d1a6cc /src/storage/phrase_large_table2.cpp | |
parent | de4af396b7c93fa5aaf386afe21e06d0ae053e75 (diff) | |
download | libpinyin-ad4e7289182d50ebd7fb040fa180a0c4b54473f6.tar.gz libpinyin-ad4e7289182d50ebd7fb040fa180a0c4b54473f6.tar.xz libpinyin-ad4e7289182d50ebd7fb040fa180a0c4b54473f6.zip |
add phrase_large_table2.cpp
Diffstat (limited to 'src/storage/phrase_large_table2.cpp')
-rw-r--r-- | src/storage/phrase_large_table2.cpp | 71 |
1 files changed, 71 insertions, 0 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; |