diff --git a/native/jni/src/suggest/core/dictionary/multi_bigram_map.cpp b/native/jni/src/suggest/core/dictionary/multi_bigram_map.cpp index 49d82e69a..105224126 100644 --- a/native/jni/src/suggest/core/dictionary/multi_bigram_map.cpp +++ b/native/jni/src/suggest/core/dictionary/multi_bigram_map.cpp @@ -17,6 +17,7 @@ #include "suggest/core/dictionary/multi_bigram_map.h" #include +#include namespace latinime { @@ -35,7 +36,7 @@ const int MultiBigramMap::BigramMap::DEFAULT_HASH_MAP_SIZE_FOR_EACH_BIGRAM_MAP = int MultiBigramMap::getBigramProbability( const DictionaryStructureWithBufferPolicy *const structurePolicy, const int wordPosition, const int nextWordPosition, const int unigramProbability) { - hash_map_compat::const_iterator mapPosition = + std::unordered_map::const_iterator mapPosition = mBigramMaps.find(wordPosition); if (mapPosition != mBigramMaps.end()) { return mapPosition->second.getBigramProbability(structurePolicy, nextWordPosition, @@ -70,7 +71,7 @@ int MultiBigramMap::BigramMap::getBigramProbability( const int nextWordPosition, const int unigramProbability) const { int bigramProbability = NOT_A_PROBABILITY; if (mBloomFilter.isInFilter(nextWordPosition)) { - const hash_map_compat::const_iterator bigramProbabilityIt = + const std::unordered_map::const_iterator bigramProbabilityIt = mBigramMap.find(nextWordPosition); if (bigramProbabilityIt != mBigramMap.end()) { bigramProbability = bigramProbabilityIt->second; diff --git a/native/jni/src/suggest/core/dictionary/multi_bigram_map.h b/native/jni/src/suggest/core/dictionary/multi_bigram_map.h index 421b2681c..195b5e22f 100644 --- a/native/jni/src/suggest/core/dictionary/multi_bigram_map.h +++ b/native/jni/src/suggest/core/dictionary/multi_bigram_map.h @@ -18,12 +18,12 @@ #define LATINIME_MULTI_BIGRAM_MAP_H #include +#include #include "defines.h" #include "suggest/core/dictionary/binary_dictionary_bigrams_iterator.h" #include "suggest/core/dictionary/bloom_filter.h" #include "suggest/core/policy/dictionary_structure_with_buffer_policy.h" -#include "utils/hash_map_compat.h" namespace latinime { @@ -63,7 +63,7 @@ class MultiBigramMap { // NOTE: The BigramMap class doesn't use DISALLOW_COPY_AND_ASSIGN() because its default // copy constructor is needed for use in hash_map. static const int DEFAULT_HASH_MAP_SIZE_FOR_EACH_BIGRAM_MAP; - hash_map_compat mBigramMap; + std::unordered_map mBigramMap; BloomFilter mBloomFilter; }; @@ -75,7 +75,7 @@ class MultiBigramMap { const int nextWordPosition, const int unigramProbability); static const size_t MAX_CACHED_PREV_WORDS_IN_BIGRAM_MAP; - hash_map_compat mBigramMaps; + std::unordered_map mBigramMaps; }; } // namespace latinime #endif // LATINIME_MULTI_BIGRAM_MAP_H diff --git a/native/jni/src/suggest/core/layout/proximity_info.h b/native/jni/src/suggest/core/layout/proximity_info.h index b72c29394..56711d1ff 100644 --- a/native/jni/src/suggest/core/layout/proximity_info.h +++ b/native/jni/src/suggest/core/layout/proximity_info.h @@ -17,10 +17,11 @@ #ifndef LATINIME_PROXIMITY_INFO_H #define LATINIME_PROXIMITY_INFO_H +#include + #include "defines.h" #include "jni.h" #include "suggest/core/layout/proximity_info_utils.h" -#include "utils/hash_map_compat.h" namespace latinime { @@ -114,7 +115,7 @@ class ProximityInfo { // Sweet spots for geometric input. Note that we have extra sweet spots only for Y coordinates. float mSweetSpotCenterYsG[MAX_KEY_COUNT_IN_A_KEYBOARD]; float mSweetSpotRadii[MAX_KEY_COUNT_IN_A_KEYBOARD]; - hash_map_compat mLowerCodePointToKeyMap; + std::unordered_map mLowerCodePointToKeyMap; int mKeyIndexToOriginalCodePoint[MAX_KEY_COUNT_IN_A_KEYBOARD]; int mKeyIndexToLowerCodePointG[MAX_KEY_COUNT_IN_A_KEYBOARD]; int mCenterXsG[MAX_KEY_COUNT_IN_A_KEYBOARD]; diff --git a/native/jni/src/suggest/core/layout/proximity_info_state.cpp b/native/jni/src/suggest/core/layout/proximity_info_state.cpp index e585f9088..91469e26d 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state.cpp +++ b/native/jni/src/suggest/core/layout/proximity_info_state.cpp @@ -21,6 +21,7 @@ #include #include // for memset() and memmove() #include // for debug prints +#include #include #include "defines.h" @@ -296,7 +297,7 @@ bool ProximityInfoState::hasSpaceProximity(const int index) const { // Returns a probability of mapping index to keyIndex. float ProximityInfoState::getProbability(const int index, const int keyIndex) const { ASSERT(0 <= index && index < mSampledInputSize); - hash_map_compat::const_iterator it = mCharProbabilities[index].find(keyIndex); + std::unordered_map::const_iterator it = mCharProbabilities[index].find(keyIndex); if (it != mCharProbabilities[index].end()) { return it->second; } diff --git a/native/jni/src/suggest/core/layout/proximity_info_state.h b/native/jni/src/suggest/core/layout/proximity_info_state.h index d66121b74..6b1a319aa 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state.h +++ b/native/jni/src/suggest/core/layout/proximity_info_state.h @@ -18,12 +18,12 @@ #define LATINIME_PROXIMITY_INFO_STATE_H #include // for memset() +#include #include #include "defines.h" #include "suggest/core/layout/proximity_info_params.h" #include "suggest/core/layout/proximity_info_state_utils.h" -#include "utils/hash_map_compat.h" namespace latinime { @@ -215,7 +215,7 @@ class ProximityInfoState { std::vector mSpeedRates; std::vector mDirections; // probabilities of skipping or mapping to a key for each point. - std::vector > mCharProbabilities; + std::vector > mCharProbabilities; // The vector for the key code set which holds nearby keys of some trailing sampled input points // for each sampled input point. These nearby keys contain the next characters which can be in // the dictionary. Specifically, currently we are looking for keys nearby trailing sampled diff --git a/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp b/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp index 72bb68fc4..ea3b02216 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp +++ b/native/jni/src/suggest/core/layout/proximity_info_state_utils.cpp @@ -20,6 +20,7 @@ #include #include // for memset() #include // for debug prints +#include #include #include "defines.h" @@ -620,7 +621,7 @@ namespace latinime { const std::vector *const sampledLengthCache, const std::vector *const sampledNormalizedSquaredLengthCache, const ProximityInfo *const proximityInfo, - std::vector > *charProbabilities) { + std::vector > *charProbabilities) { charProbabilities->resize(sampledInputSize); // Calculates probabilities of using a point as a correlated point with the character // for each point. @@ -762,7 +763,7 @@ namespace latinime { sstream << "Speed: "<< (*sampledSpeedRates)[i] << ", "; sstream << "Angle: "<< getPointAngle(sampledInputXs, sampledInputYs, i) << ", \n"; - for (hash_map_compat::iterator it = (*charProbabilities)[i].begin(); + for (std::unordered_map::iterator it = (*charProbabilities)[i].begin(); it != (*charProbabilities)[i].end(); ++it) { if (it->first == NOT_AN_INDEX) { sstream << it->first @@ -804,7 +805,7 @@ namespace latinime { // Converting from raw probabilities to log probabilities to calculate spatial distance. for (int i = start; i < sampledInputSize; ++i) { for (int j = 0; j < keyCount; ++j) { - hash_map_compat::iterator it = (*charProbabilities)[i].find(j); + std::unordered_map::iterator it = (*charProbabilities)[i].find(j); if (it == (*charProbabilities)[i].end()){ continue; } else if(it->second < ProximityInfoParams::MIN_PROBABILITY) { @@ -821,7 +822,7 @@ namespace latinime { /* static */ void ProximityInfoStateUtils::updateSampledSearchKeySets( const ProximityInfo *const proximityInfo, const int sampledInputSize, const int lastSavedInputSize, const std::vector *const sampledLengthCache, - const std::vector > *const charProbabilities, + const std::vector > *const charProbabilities, std::vector *sampledSearchKeySets, std::vector > *sampledSearchKeyVectors) { sampledSearchKeySets->resize(sampledInputSize); @@ -867,7 +868,7 @@ namespace latinime { /* static */ bool ProximityInfoStateUtils::suppressCharProbabilities(const int mostCommonKeyWidth, const int sampledInputSize, const std::vector *const lengthCache, const int index0, const int index1, - std::vector > *charProbabilities) { + std::vector > *charProbabilities) { ASSERT(0 <= index0 && index0 < sampledInputSize); ASSERT(0 <= index1 && index1 < sampledInputSize); const float keyWidthFloat = static_cast(mostCommonKeyWidth); @@ -878,9 +879,9 @@ namespace latinime { const float suppressionRate = ProximityInfoParams::MIN_SUPPRESSION_RATE + diff / keyWidthFloat / ProximityInfoParams::SUPPRESSION_LENGTH_WEIGHT * ProximityInfoParams::SUPPRESSION_WEIGHT; - for (hash_map_compat::iterator it = (*charProbabilities)[index0].begin(); + for (std::unordered_map::iterator it = (*charProbabilities)[index0].begin(); it != (*charProbabilities)[index0].end(); ++it) { - hash_map_compat::iterator it2 = (*charProbabilities)[index1].find(it->first); + std::unordered_map::iterator it2 = (*charProbabilities)[index1].find(it->first); if (it2 != (*charProbabilities)[index1].end() && it->second < it2->second) { const float newProbability = it->second * suppressionRate; const float suppression = it->second - newProbability; @@ -932,7 +933,7 @@ namespace latinime { // returns probability of generating the word. /* static */ float ProximityInfoStateUtils::getMostProbableString( const ProximityInfo *const proximityInfo, const int sampledInputSize, - const std::vector > *const charProbabilities, + const std::vector > *const charProbabilities, int *const codePointBuf) { ASSERT(sampledInputSize >= 0); memset(codePointBuf, 0, sizeof(codePointBuf[0]) * MAX_WORD_LENGTH); @@ -942,7 +943,7 @@ namespace latinime { for (int i = 0; i < sampledInputSize && index < MAX_WORD_LENGTH - 1; ++i) { float minLogProbability = static_cast(MAX_VALUE_FOR_WEIGHTING); int character = NOT_AN_INDEX; - for (hash_map_compat::const_iterator it = (*charProbabilities)[i].begin(); + for (std::unordered_map::const_iterator it = (*charProbabilities)[i].begin(); it != (*charProbabilities)[i].end(); ++it) { const float logProbability = (it->first != NOT_AN_INDEX) ? it->second + ProximityInfoParams::DEMOTION_LOG_PROBABILITY : it->second; diff --git a/native/jni/src/suggest/core/layout/proximity_info_state_utils.h b/native/jni/src/suggest/core/layout/proximity_info_state_utils.h index 7aa20c3d1..71e83a80c 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_state_utils.h +++ b/native/jni/src/suggest/core/layout/proximity_info_state_utils.h @@ -18,10 +18,10 @@ #define LATINIME_PROXIMITY_INFO_STATE_UTILS_H #include +#include #include #include "defines.h" -#include "utils/hash_map_compat.h" namespace latinime { class ProximityInfo; @@ -29,7 +29,7 @@ class ProximityInfoParams; class ProximityInfoStateUtils { public: - typedef hash_map_compat NearKeysDistanceMap; + typedef std::unordered_map NearKeysDistanceMap; typedef std::bitset NearKeycodesSet; static int trimLastTwoTouchPoints(std::vector *sampledInputXs, @@ -72,11 +72,11 @@ class ProximityInfoStateUtils { const std::vector *const sampledLengthCache, const std::vector *const sampledNormalizedSquaredLengthCache, const ProximityInfo *const proximityInfo, - std::vector > *charProbabilities); + std::vector > *charProbabilities); static void updateSampledSearchKeySets(const ProximityInfo *const proximityInfo, const int sampledInputSize, const int lastSavedInputSize, const std::vector *const sampledLengthCache, - const std::vector > *const charProbabilities, + const std::vector > *const charProbabilities, std::vector *sampledSearchKeySets, std::vector > *sampledSearchKeyVectors); static float getPointToKeyByIdLength(const float maxPointToKeyLength, @@ -105,7 +105,7 @@ class ProximityInfoStateUtils { // TODO: Move to most_probable_string_utils.h static float getMostProbableString(const ProximityInfo *const proximityInfo, const int sampledInputSize, - const std::vector > *const charProbabilities, + const std::vector > *const charProbabilities, int *const codePointBuf); private: @@ -147,7 +147,7 @@ class ProximityInfoStateUtils { const int index2); static bool suppressCharProbabilities(const int mostCommonKeyWidth, const int sampledInputSize, const std::vector *const lengthCache, const int index0, - const int index1, std::vector > *charProbabilities); + const int index1, std::vector > *charProbabilities); static float calculateSquaredDistanceFromSweetSpotCenter( const ProximityInfo *const proximityInfo, const std::vector *const sampledInputXs, const std::vector *const sampledInputYs, const int keyIndex, diff --git a/native/jni/src/suggest/core/layout/proximity_info_utils.h b/native/jni/src/suggest/core/layout/proximity_info_utils.h index c273ef456..178aada2d 100644 --- a/native/jni/src/suggest/core/layout/proximity_info_utils.h +++ b/native/jni/src/suggest/core/layout/proximity_info_utils.h @@ -18,18 +18,18 @@ #define LATINIME_PROXIMITY_INFO_UTILS_H #include +#include #include "defines.h" #include "suggest/core/layout/additional_proximity_chars.h" #include "suggest/core/layout/geometry_utils.h" #include "utils/char_utils.h" -#include "utils/hash_map_compat.h" namespace latinime { class ProximityInfoUtils { public: static AK_FORCE_INLINE int getKeyIndexOf(const int keyCount, const int c, - const hash_map_compat *const codeToKeyMap) { + const std::unordered_map *const codeToKeyMap) { if (keyCount == 0) { // We do not have the coordinate data return NOT_AN_INDEX; @@ -38,7 +38,7 @@ class ProximityInfoUtils { return NOT_AN_INDEX; } const int lowerCode = CharUtils::toLowerCase(c); - hash_map_compat::const_iterator mapPos = codeToKeyMap->find(lowerCode); + std::unordered_map::const_iterator mapPos = codeToKeyMap->find(lowerCode); if (mapPos != codeToKeyMap->end()) { return mapPos->second; } @@ -52,7 +52,7 @@ class ProximityInfoUtils { const int *const proximityCharsArray, const int cellHeight, const int cellWidth, const int gridWidth, const int mostCommonKeyWidth, const int keyCount, const char *const localeStr, - const hash_map_compat *const codeToKeyMap, int *inputProximities) { + const std::unordered_map *const codeToKeyMap, int *inputProximities) { // Initialize // - mInputCodes // - mNormalizedSquaredDistances @@ -144,7 +144,7 @@ class ProximityInfoUtils { const int *const proximityCharsArray, const int cellHeight, const int cellWidth, const int gridWidth, const int mostCommonKeyWidth, const int keyCount, const int x, const int y, const int primaryKey, const char *const localeStr, - const hash_map_compat *const codeToKeyMap, int *proximities) { + const std::unordered_map *const codeToKeyMap, int *proximities) { const int mostCommonKeyWidthSquare = mostCommonKeyWidth * mostCommonKeyWidth; int insertPos = 0; proximities[insertPos++] = primaryKey; diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_gc_event_listeners.h b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_gc_event_listeners.h index d8867754d..2aa402748 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_gc_event_listeners.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_gc_event_listeners.h @@ -23,7 +23,6 @@ #include "suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_reading_helper.h" #include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_writer.h" #include "suggest/policyimpl/dictionary/utils/buffer_with_extendable_buffer.h" -#include "utils/hash_map_compat.h" namespace latinime { diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_updating_helper.h b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_updating_helper.h index f703baf85..9b2815263 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_updating_helper.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/dynamic_pt_updating_helper.h @@ -19,7 +19,6 @@ #include "defines.h" #include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h" -#include "utils/hash_map_compat.h" namespace latinime { diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_writer.h b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_writer.h index 84dd6870e..e843f074a 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_writer.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/pt_common/pt_node_writer.h @@ -17,18 +17,18 @@ #ifndef LATINIME_PT_NODE_WRITER_H #define LATINIME_PT_NODE_WRITER_H -#include "defines.h" +#include +#include "defines.h" #include "suggest/policyimpl/dictionary/structure/pt_common/pt_node_params.h" -#include "utils/hash_map_compat.h" namespace latinime { // Interface class used to write PtNode information. class PtNodeWriter { public: - typedef hash_map_compat PtNodeArrayPositionRelocationMap; - typedef hash_map_compat PtNodePositionRelocationMap; + typedef std::unordered_map PtNodeArrayPositionRelocationMap; + typedef std::unordered_map PtNodePositionRelocationMap; struct DictPositionRelocationMap { public: DictPositionRelocationMap() diff --git a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/terminal_position_lookup_table.h b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/terminal_position_lookup_table.h index f73e22754..816059560 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/terminal_position_lookup_table.h +++ b/native/jni/src/suggest/policyimpl/dictionary/structure/v4/content/terminal_position_lookup_table.h @@ -17,16 +17,17 @@ #ifndef LATINIME_TERMINAL_POSITION_LOOKUP_TABLE_H #define LATINIME_TERMINAL_POSITION_LOOKUP_TABLE_H +#include + #include "defines.h" #include "suggest/policyimpl/dictionary/structure/v4/content/single_dict_content.h" #include "suggest/policyimpl/dictionary/structure/v4/ver4_dict_constants.h" -#include "utils/hash_map_compat.h" namespace latinime { class TerminalPositionLookupTable : public SingleDictContent { public: - typedef hash_map_compat TerminalIdMap; + typedef std::unordered_map TerminalIdMap; TerminalPositionLookupTable(const char *const dictPath, const bool isUpdatable) : SingleDictContent(dictPath, diff --git a/native/jni/src/utils/hash_map_compat.h b/native/jni/src/utils/hash_map_compat.h deleted file mode 100644 index 7bf35a660..000000000 --- a/native/jni/src/utils/hash_map_compat.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (C) 2012 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_HASH_MAP_COMPAT_H -#define LATINIME_HASH_MAP_COMPAT_H - -#include - -#define hash_map_compat std::unordered_map - -#if 0 // TODO: Use this instead of the above macro. -template using hash_map_compat = std::unordered_map; -#endif - -#endif // LATINIME_HASH_MAP_COMPAT_H