mem-ruby: Allow MachineID to be unordered key
Define an std::hash function so that MachineID may be used as a key type for unordered STL containers. Change-Id: Ibc3bc78149c69683207d8967542fa6e8d545f75c Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/29652 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -67,6 +67,16 @@ operator!=(const MachineID & obj1, const MachineID & obj2)
|
||||
return (obj1.type != obj2.type || obj1.num != obj2.num);
|
||||
}
|
||||
|
||||
namespace std {
|
||||
template<>
|
||||
struct hash<MachineID> {
|
||||
inline size_t operator()(const MachineID& id) const {
|
||||
size_t hval = MachineType_base_level(id.type) << 16 | id.num;
|
||||
return hval;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Output operator declaration
|
||||
std::ostream& operator<<(std::ostream& out, const MachineID& obj);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user