From 888fae7b49f5d39f2371edb78566476396e30c75 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 18 Feb 2013 16:03:04 +0000 Subject: Add front/back/erase to MapVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175449 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/MapVector.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/MapVector.h b/include/llvm/ADT/MapVector.h index f29681f644..405fc43978 100644 --- a/include/llvm/ADT/MapVector.h +++ b/include/llvm/ADT/MapVector.h @@ -64,6 +64,11 @@ public: return Vector.empty(); } + std::pair &front() { return Vector.front(); } + const std::pair &front() const { return Vector.front(); } + std::pair &back() { return Vector.back(); } + const std::pair &back() const { return Vector.back(); } + void clear() { Map.clear(); Vector.clear(); @@ -113,6 +118,16 @@ public: return Pos == Map.end()? Vector.end() : (Vector.begin() + Pos->second); } + + /// \brief Erase entry with the given key. + void erase(const KeyT &key) { + typename MapType::iterator Pos = Map.find(key); + if (Pos == Map.end()) + return; + + Vector.erase(Vector.begin() + Pos->second); + Map.erase(Pos); + } }; } -- cgit v1.2.3-18-g5258