Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/prediction/suggest/core/dictionary/binary_dictionary_bigrams_iterator.h

Issue 1247903003: Add spellcheck and word suggestion to the prediction service (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/prediction/suggest/core/dictionary/binary_dictionary_bigrams_iterator.h
diff --git a/third_party/prediction/suggest/core/dictionary/binary_dictionary_bigrams_iterator.h b/third_party/prediction/suggest/core/dictionary/binary_dictionary_bigrams_iterator.h
new file mode 100644
index 0000000000000000000000000000000000000000..a02b2c4bdf294d6c0a5114aa3ec856b1ed0ac166
--- /dev/null
+++ b/third_party/prediction/suggest/core/dictionary/binary_dictionary_bigrams_iterator.h
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LATINIME_BINARY_DICTIONARY_BIGRAMS_ITERATOR_H
+#define LATINIME_BINARY_DICTIONARY_BIGRAMS_ITERATOR_H
+
+#include "third_party/prediction/defines.h"
+#include "third_party/prediction/suggest/core/policy/dictionary_bigrams_structure_policy.h"
+
+namespace latinime {
+
+class BinaryDictionaryBigramsIterator {
+ public:
+ // Empty iterator.
+ BinaryDictionaryBigramsIterator()
+ : mBigramsStructurePolicy(nullptr),
+ mPos(NOT_A_DICT_POS),
+ mBigramPos(NOT_A_DICT_POS),
+ mProbability(NOT_A_PROBABILITY),
+ mHasNext(false) {}
+
+ BinaryDictionaryBigramsIterator(
+ const DictionaryBigramsStructurePolicy* const bigramsStructurePolicy,
+ const int pos)
+ : mBigramsStructurePolicy(bigramsStructurePolicy),
+ mPos(pos),
+ mBigramPos(NOT_A_DICT_POS),
+ mProbability(NOT_A_PROBABILITY),
+ mHasNext(pos != NOT_A_DICT_POS) {}
+
+ BinaryDictionaryBigramsIterator(
+ BinaryDictionaryBigramsIterator&& bigramsIterator)
+ : mBigramsStructurePolicy(bigramsIterator.mBigramsStructurePolicy),
+ mPos(bigramsIterator.mPos),
+ mBigramPos(bigramsIterator.mBigramPos),
+ mProbability(bigramsIterator.mProbability),
+ mHasNext(bigramsIterator.mHasNext) {}
+
+ AK_FORCE_INLINE bool hasNext() const { return mHasNext; }
+
+ AK_FORCE_INLINE void next() {
+ mBigramsStructurePolicy->getNextBigram(&mBigramPos, &mProbability,
+ &mHasNext, &mPos);
+ }
+
+ AK_FORCE_INLINE int getProbability() const { return mProbability; }
+
+ AK_FORCE_INLINE int getBigramPos() const { return mBigramPos; }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(BinaryDictionaryBigramsIterator);
+
+ const DictionaryBigramsStructurePolicy* const mBigramsStructurePolicy;
+ int mPos;
+ int mBigramPos;
+ int mProbability;
+ bool mHasNext;
+};
+} // namespace latinime
+#endif // LATINIME_BINARY_DICTIONARY_BIGRAMS_ITERATOR_H

Powered by Google App Engine
This is Rietveld 408576698