diff options
author | Alex Zolotarev <alex@mapswithme.com> | 2014-08-07 01:45:40 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:25:03 +0300 |
commit | baf239aef8bfbc76b2e1b09c5dc59b8463160a3b (patch) | |
tree | c9896e450a4a8a7113b94a74809d7dbc7cb98eeb /search/feature_offset_match.hpp | |
parent | 180657e756fefbe5d601c64b860ee470217b4956 (diff) |
[c++11] Migrated from scoped_ptr to unique_ptr
Diffstat (limited to 'search/feature_offset_match.hpp')
-rw-r--r-- | search/feature_offset_match.hpp | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/search/feature_offset_match.hpp b/search/feature_offset_match.hpp index feb4bd77d8..78326b2fca 100644 --- a/search/feature_offset_match.hpp +++ b/search/feature_offset_match.hpp @@ -9,7 +9,7 @@ #include "../base/mutex.hpp" #include "../std/algorithm.hpp" -#include "../std/scoped_ptr.hpp" +#include "../std/unique_ptr.hpp" #include "../std/unordered_set.hpp" #include "../std/utility.hpp" #include "../std/vector.hpp" @@ -40,7 +40,7 @@ TrieIterator * MoveTrieIteratorToString(TrieIterator const & trieRoot, symbolsMatched = 0; bFullEdgeMatched = false; - scoped_ptr<search::TrieIterator> pIter(trieRoot.Clone()); + unique_ptr<search::TrieIterator> pIter(trieRoot.Clone()); size_t const szQuery = queryS.size(); while (symbolsMatched < szQuery) @@ -105,7 +105,7 @@ void FullMatchInTrie(TrieIterator const & trieRoot, size_t symbolsMatched = 0; bool bFullEdgeMatched; - scoped_ptr<search::TrieIterator> pIter( + unique_ptr<search::TrieIterator> const pIter( MoveTrieIteratorToString(trieRoot, s, symbolsMatched, bFullEdgeMatched)); if (!pIter || !bFullEdgeMatched || symbolsMatched != s.size()) @@ -156,7 +156,7 @@ void PrefixMatchInTrie(TrieIterator const & trieRoot, { // Next 2 lines don't throw any exceptions while moving // ownership from container to smart pointer. - scoped_ptr<search::TrieIterator> pIter(trieQueue.back()); + unique_ptr<search::TrieIterator> const pIter(trieQueue.back()); trieQueue.pop_back(); for (size_t i = 0; i < pIter->m_value.size(); ++i) @@ -189,24 +189,13 @@ template <class FilterT> class OffsetIntersecter typedef unordered_set<ValueT, HashFn, EqualFn> SetType; FilterT const & m_filter; - scoped_ptr<SetType> m_prevSet; - scoped_ptr<SetType> m_set; - - void InitSet(scoped_ptr<SetType> & ptr) - { - ptr.reset(new SetType()); - - // this is not std compatible, but important for google::dense_hash_set - //ValueT zero; - //zero.m_featureId = 0; - //ptr->set_empty_key(zero); - } + unique_ptr<SetType> m_prevSet; + unique_ptr<SetType> m_set; public: explicit OffsetIntersecter(FilterT const & filter) - : m_filter(filter) + : m_filter(filter), m_set(new SetType) { - InitSet(m_set); } void operator() (ValueT const & v) @@ -223,7 +212,7 @@ public: void NextStep() { if (!m_prevSet) - InitSet(m_prevSet); + m_prevSet.reset(new SetType); m_prevSet.swap(m_set); m_set->clear(); |