summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeng Wu <alexepico@gmail.com>2012-09-03 09:53:19 +0800
committerPeng Wu <alexepico@gmail.com>2012-09-03 09:53:19 +0800
commit930426a28be0774339950c508d5bb324961d0710 (patch)
tree7448cbfc322f015eef75532936cda9e4a6352624
parent4f3e1e5075b998b08dcec7d11d85ffb098ca9dcb (diff)
downloadlibpinyin-930426a28be0774339950c508d5bb324961d0710.tar.gz
libpinyin-930426a28be0774339950c508d5bb324961d0710.tar.xz
libpinyin-930426a28be0774339950c508d5bb324961d0710.zip
write get_first_token
-rw-r--r--src/storage/phrase_large_table2.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/storage/phrase_large_table2.h b/src/storage/phrase_large_table2.h
index 01adb83..c4d4092 100644
--- a/src/storage/phrase_large_table2.h
+++ b/src/storage/phrase_large_table2.h
@@ -108,6 +108,26 @@ public:
}
};
+/* for compatibility. */
+static inline int get_first_token(PhraseTokens tokens,
+ /* out */ phrase_token_t & token){
+ int num = 0; token = null_token;
+
+ for (size_t i = 0; i < PHRASE_INDEX_LIBRARY_COUNT; ++i) {
+ GArray * array = tokens[i];
+ if (NULL == array || 0 == array->len)
+ continue;
+
+ num += array->len;
+
+ if (null_token == token) {
+ token = g_array_index(array, phrase_token_t, 0);
+ }
+ }
+
+ return num;
+}
+
};
#endif