diff options
Diffstat (limited to 'src/storage')
-rw-r--r-- | src/storage/phrase_large_table3.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/storage/phrase_large_table3.cpp b/src/storage/phrase_large_table3.cpp index 6587b75..f89f166 100644 --- a/src/storage/phrase_large_table3.cpp +++ b/src/storage/phrase_large_table3.cpp @@ -122,6 +122,31 @@ int PhraseTableEntry::get_length() const { return begin - end; } +/* mask out method */ + +bool PhraseTableEntry::mask_out(phrase_token_t mask, phrase_token_t value) { + const char * content = (char *) m_chunk.begin() + + sizeof(table_entry_header_t); + const phrase_token_t * begin = (phrase_token_t *) content; + const phrase_token_t * end = (phrase_token_t *) m_chunk.end(); + + const phrase_token_t * cur_token; + for (cur_token = begin; cur_token != end; ++cur_token) { + if ((*cur_token & mask) != value) + continue; + + int offset = sizeof(table_entry_header_t) /* header */ + + (cur_token - begin) * sizeof(phrase_token_t); + m_chunk.remove_content(offset, sizeof(phrase_token_t)); + + /* update chunk end. */ + end = (phrase_token_t *) m_chunk.end(); + --cur_token; + } + + return true; +} + /* load text method */ |