diff options
author | Eddie Hung <eddie.hung+gitlab@gmail.com> | 2018-07-21 19:04:14 +0000 |
---|---|---|
committer | Eddie Hung <eddie.hung+gitlab@gmail.com> | 2018-07-21 19:04:14 +0000 |
commit | dfdeb21690181044a95c2b2d64c197c999507b0c (patch) | |
tree | a7c74ddc6c085830880ceffdb9f15d8c84afc3fe /common/nextpnr.h | |
parent | 6e7ba2a2be87bb1e0f323128283a87f59af596b7 (diff) | |
parent | f438fc615b829170679971110b5d1bb57fba6a86 (diff) | |
download | nextpnr-dfdeb21690181044a95c2b2d64c197c999507b0c.tar.gz nextpnr-dfdeb21690181044a95c2b2d64c197c999507b0c.tar.bz2 nextpnr-dfdeb21690181044a95c2b2d64c197c999507b0c.zip |
Merge branch 'master' into 'master'
Master
See merge request eddiehung/nextpnr!6
Diffstat (limited to 'common/nextpnr.h')
-rw-r--r-- | common/nextpnr.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/common/nextpnr.h b/common/nextpnr.h index bc64adb5..40fd3d13 100644 --- a/common/nextpnr.h +++ b/common/nextpnr.h @@ -27,6 +27,8 @@ #include <unordered_set> #include <vector> +#include <boost/functional/hash.hpp> + #ifndef NEXTPNR_H #define NEXTPNR_H @@ -158,8 +160,30 @@ struct GraphicElement std::string text; }; +struct Loc +{ + int x = -1, y = -1, z = -1; + + bool operator==(const Loc &other) const { return (x == other.x) && (y == other.y) && (z == other.z); } + bool operator!=(const Loc &other) const { return (x != other.x) || (y != other.y) || (z == other.z); } +}; + NEXTPNR_NAMESPACE_END +namespace std { +template <> struct hash<NEXTPNR_NAMESPACE_PREFIX Loc> +{ + std::size_t operator()(const NEXTPNR_NAMESPACE_PREFIX Loc &obj) const noexcept + { + std::size_t seed = 0; + boost::hash_combine(seed, hash<int>()(obj.x)); + boost::hash_combine(seed, hash<int>()(obj.y)); + boost::hash_combine(seed, hash<int>()(obj.z)); + return seed; + } +}; +} // namespace std + #include "archdefs.h" NEXTPNR_NAMESPACE_BEGIN |