diff options
-rw-r--r-- | include/llvm/ADT/MapVector.h | 15 |
1 files changed, 15 insertions, 0 deletions
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<KeyT, ValueT> &front() { return Vector.front(); } + const std::pair<KeyT, ValueT> &front() const { return Vector.front(); } + std::pair<KeyT, ValueT> &back() { return Vector.back(); } + const std::pair<KeyT, ValueT> &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); + } }; } |