summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2016-03-02 15:22:50 +0800
committerPeng Wu <alexepico@gmail.com>2016-03-02 15:22:50 +0800
commitf3c74ca5eb43801efd396e030579a1b4d53decbc (patch)
tree89250befcbd18a46778f9274b09db62198263ba7 /src
parentb176ce01e4c7aaa67b16511ecf82e963e67e33df (diff)
downloadlibpinyin-f3c74ca5eb43801efd396e030579a1b4d53decbc.tar.gz
libpinyin-f3c74ca5eb43801efd396e030579a1b4d53decbc.tar.xz
libpinyin-f3c74ca5eb43801efd396e030579a1b4d53decbc.zip
write get_length method
Diffstat (limited to 'src')
-rw-r--r--src/storage/chewing_large_table2.h7
-rw-r--r--src/storage/phrase_large_table3.cpp2
2 files changed, 7 insertions, 2 deletions
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 */