From f3c74ca5eb43801efd396e030579a1b4d53decbc Mon Sep 17 00:00:00 2001 From: Peng Wu Date: Wed, 2 Mar 2016 15:22:50 +0800 Subject: write get_length method --- src/storage/chewing_large_table2.h | 7 ++++++- src/storage/phrase_large_table3.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/storage/chewing_large_table2.h b/src/storage/chewing_large_table2.h index e9a64bd..9a20a2b 100644 --- a/src/storage/chewing_large_table2.h +++ b/src/storage/chewing_large_table2.h @@ -172,7 +172,12 @@ public: } /* get length method */ - int get_length() const; + int get_length() const { + const IndexItem * begin = (IndexItem *) m_chunk.begin(); + const IndexItem * end = (IndexItem *) m_chunk.end(); + + return end - begin; + } /* mask out method */ bool mask_out(phrase_token_t mask, phrase_token_t value); diff --git a/src/storage/phrase_large_table3.cpp b/src/storage/phrase_large_table3.cpp index f1ae3e9..a769d0b 100644 --- a/src/storage/phrase_large_table3.cpp +++ b/src/storage/phrase_large_table3.cpp @@ -94,7 +94,7 @@ int PhraseTableEntry::get_length() const { const phrase_token_t * begin = (phrase_token_t *) m_chunk.begin(); const phrase_token_t * end = (phrase_token_t *) m_chunk.end(); - return begin - end; + return end - begin; } /* mask out method */ -- cgit