From c9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c Mon Sep 17 00:00:00 2001 From: Martial Simon Date: Mon, 15 Sep 2025 01:08:27 +0200 Subject: add: graphs et rushs --- graphs/cpp/bimap/bimap.hh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 graphs/cpp/bimap/bimap.hh (limited to 'graphs/cpp/bimap/bimap.hh') diff --git a/graphs/cpp/bimap/bimap.hh b/graphs/cpp/bimap/bimap.hh new file mode 100644 index 0000000..25f459d --- /dev/null +++ b/graphs/cpp/bimap/bimap.hh @@ -0,0 +1,36 @@ +#pragma once + +#include + + template + class Bimap +{ + static_assert(!std::is_same_v, + "Lhs and Rhs must be different types"); + using mapLhs = std::map; + using mapRhs = std::map; + using iteratorLhs = typename mapLhs::const_iterator; + using iteratorRhs = typename mapRhs::const_iterator; + +public: + bool insert(const Lhs& vl, const Rhs& vr); + bool insert(const Rhs& vr, const Lhs& vl); + + std::size_t erase(const Lhs& vl); + std::size_t erase(const Rhs& vr); + + iteratorLhs find(const Lhs& vl) const; + iteratorRhs find(const Rhs& vr) const; + + std::size_t size() const; + void clear(); + + const mapLhs& get_lhs() const; + const mapRhs& get_rhs() const; + +private: + mapLhs lhs_; + mapRhs rhs_; +}; + +#include "bimap.hxx" -- cgit v1.2.3