Skip to content

Commit

Permalink
removed boost dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
camolezi committed Jun 4, 2020
1 parent 442ae07 commit 3f16ad6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions RecoLocalMuon/DTSegment/src/DTCombinatorialPatternReco.h
Expand Up @@ -12,7 +12,6 @@

/* Base Class Headers */
#include "RecoLocalMuon/DTSegment/src/DTRecSegment2DBaseAlgo.h"
#include <boost/unordered_set.hpp>

/* Collaborating Class Declarations */
namespace edm {
Expand All @@ -26,9 +25,11 @@ class DTHitPairForFit;
class DTSegmentCand;

/* C++ Headers */
#include <vector>
#include <deque>
#include <functional>
#include <unordered_set>
#include <utility>
#include <vector>

#include "Geometry/DTGeometry/interface/DTGeometry.h"
#include "FWCore/Framework/interface/ESHandle.h"
Expand Down Expand Up @@ -117,9 +118,16 @@ class DTCombinatorialPatternReco : public DTRecSegment2DBaseAlgo {
(values_ == other.values_); // expensive last resort
}

//Same implementation as boost::hash_combine
template <class T>
inline void hash_combine(std::size_t& seed, const T& v) {
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}

/// push back value, and update the hash
void push_back(short unsigned int i) {
boost::hash_combine(hash_, i);
hash_combine(hash_, i);
values_.push_back(i);
}
/// return the hash: equal objects MUST have the same hash,
Expand All @@ -132,15 +140,22 @@ class DTCombinatorialPatternReco : public DTRecSegment2DBaseAlgo {
const_iterator end() const { return values_.end(); }
values::size_type size() const { return values_.size(); }

//Custom hash functor for std::unordered_set
class HashFunction {
public:
size_t operator()(const TriedPattern& p) const { return p.hash(); }
};

private:
values values_;
size_t hash_;
};
typedef boost::unordered_set<TriedPattern> TriedPatterns;
typedef std::unordered_set<TriedPattern, TriedPattern::HashFunction> TriedPatterns;

private:
TriedPatterns theTriedPattern;
};

inline std::size_t hash_value(const DTCombinatorialPatternReco::TriedPattern& t) { return t.hash(); }

#endif // DTSegment_DTCombinatorialPatternReco_h

0 comments on commit 3f16ad6

Please sign in to comment.