diff options
author | Peng Wu <alexepico@gmail.com> | 2010-08-18 14:58:57 +0800 |
---|---|---|
committer | Peng Wu <alexepico@gmail.com> | 2010-08-18 14:58:57 +0800 |
commit | 6f3ee371d7118ac04327a7654a519657e8981edd (patch) | |
tree | b1de5338007b83f3babf9805831ff3f0aff56724 /src/storage/phrase_index.cpp | |
parent | 6f8c022c759f7930449596bdad0bcc9b23cdcb41 (diff) | |
download | libpinyin-6f3ee371d7118ac04327a7654a519657e8981edd.tar.gz libpinyin-6f3ee371d7118ac04327a7654a519657e8981edd.tar.xz libpinyin-6f3ee371d7118ac04327a7654a519657e8981edd.zip |
add get_range to phrase index
Diffstat (limited to 'src/storage/phrase_index.cpp')
-rw-r--r-- | src/storage/phrase_index.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/storage/phrase_index.cpp b/src/storage/phrase_index.cpp index c122803..d7fb4fd 100644 --- a/src/storage/phrase_index.cpp +++ b/src/storage/phrase_index.cpp @@ -327,3 +327,27 @@ bool FacadePhraseIndex::load_text(guint8 phrase_index, FILE * infile){ m_total_freq += m_sub_phrase_indices[phrase_index]->get_phrase_index_total_freq(); return true; } + +int FacadePhraseIndex::get_range(guint8 phrase_index, /* out */ PhraseIndexRange & range){ + SubPhraseIndex * sub_phrase = m_sub_phrase_indices[phrase_index]; + if ( !sub_phrase ) + return ERROR_NO_SUB_PHRASE_INDEX; + + int result = sub_phrase->get_range(range); + if ( result ) + return result; + + range.m_range_begin = PHRASE_INDEX_MAKE_TOKEN(phrase_index, range.m_range_begin); + range.m_range_end = PHRASE_INDEX_MAKE_TOKEN(phrase_index, range.m_range_end); + return ERROR_OK; +} + +int SubPhraseIndex::get_range(/* out */ PhraseIndexRange & range){ + const table_offset_t * begin = (const table_offset_t *)m_phrase_index.begin(); + const table_offset_t * end = (const table_offset_t *)m_phrase_index.end(); + + range.m_range_begin = 0; + range.m_range_end = end - begin; + + return ERROR_OK; +} |