diff options
author | Paul Baltescu <pauldb89@gmail.com> | 2013-06-04 23:17:57 +0100 |
---|---|---|
committer | Paul Baltescu <pauldb89@gmail.com> | 2013-06-04 23:17:57 +0100 |
commit | 02099a01350a41a99ec400e9b29df08a01d88979 (patch) | |
tree | b5af245aa6c7e00e3d4b088c9e7e3b893d080a26 /extractor/suffix_array.cc | |
parent | 891502bdd646c21954684763f322b107568a072e (diff) |
Serialize data structures.
Diffstat (limited to 'extractor/suffix_array.cc')
-rw-r--r-- | extractor/suffix_array.cc | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/extractor/suffix_array.cc b/extractor/suffix_array.cc index 65b2d581..0cf4d1f6 100644 --- a/extractor/suffix_array.cc +++ b/extractor/suffix_array.cc @@ -186,20 +186,6 @@ shared_ptr<DataArray> SuffixArray::GetData() const { return data_array; } -void SuffixArray::WriteBinary(const fs::path& filepath) const { - FILE* file = fopen(filepath.string().c_str(), "w"); - assert(file); - data_array->WriteBinary(file); - - int size = suffix_array.size(); - fwrite(&size, sizeof(int), 1, file); - fwrite(suffix_array.data(), sizeof(int), size, file); - - size = word_start.size(); - fwrite(&size, sizeof(int), 1, file); - fwrite(word_start.data(), sizeof(int), size, file); -} - PhraseLocation SuffixArray::Lookup(int low, int high, const string& word, int offset) const { if (!data_array->HasWord(word)) { @@ -232,4 +218,10 @@ int SuffixArray::LookupRangeStart(int low, int high, int word_id, return result; } +bool SuffixArray::operator==(const SuffixArray& other) const { + return *data_array == *other.data_array && + suffix_array == other.suffix_array && + word_start == other.word_start; +} + } // namespace extractor |