From 60ae3e0be5374478183362005f7c48809924ef01 Mon Sep 17 00:00:00 2001 From: Keisuke Kuroyanagi Date: Wed, 30 Jul 2014 20:38:34 +0900 Subject: [PATCH] Add TrieMap.save(). Bug: 14425059 Change-Id: Ie0b4fe8b9a157da0401bb277c703ab084d5bf9cc --- .../src/suggest/policyimpl/dictionary/utils/trie_map.cpp | 7 +++++++ .../jni/src/suggest/policyimpl/dictionary/utils/trie_map.h | 3 +++ 2 files changed, 10 insertions(+) diff --git a/native/jni/src/suggest/policyimpl/dictionary/utils/trie_map.cpp b/native/jni/src/suggest/policyimpl/dictionary/utils/trie_map.cpp index c70047638..ca79c18e5 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/utils/trie_map.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/utils/trie_map.cpp @@ -16,6 +16,8 @@ #include "suggest/policyimpl/dictionary/utils/trie_map.h" +#include "suggest/policyimpl/dictionary/utils/dict_file_writing_utils.h" + namespace latinime { const int TrieMap::INVALID_INDEX = -1; @@ -98,6 +100,11 @@ bool TrieMap::put(const int key, const uint64_t value, const int bitmapEntryInde return putInternal(unsignedKey, value, getBitShuffledKey(unsignedKey), bitmapEntryIndex, readEntry(bitmapEntryIndex), 0 /* level */); } + +bool TrieMap::save(FILE *const file) const { + return DictFileWritingUtils::writeBufferToFileTail(file, &mBuffer); +} + /** * Iterate next entry in a certain level. * diff --git a/native/jni/src/suggest/policyimpl/dictionary/utils/trie_map.h b/native/jni/src/suggest/policyimpl/dictionary/utils/trie_map.h index b5bcc3bc8..db278f5f1 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/utils/trie_map.h +++ b/native/jni/src/suggest/policyimpl/dictionary/utils/trie_map.h @@ -19,6 +19,7 @@ #include #include +#include #include #include "defines.h" @@ -192,6 +193,8 @@ class TrieMap { return TrieMapRange(this, bitmapEntryIndex); } + bool save(FILE *const file) const; + private: DISALLOW_COPY_AND_ASSIGN(TrieMap);