diff options
author | Douglas Gregor <dgregor@apple.com> | 2013-02-18 16:03:04 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2013-02-18 16:03:04 +0000 |
commit | 888fae7b49f5d39f2371edb78566476396e30c75 (patch) | |
tree | fdc7bbf601bd5bc4128d8891216b3497a7c522b2 | |
parent | e3111964a0902bc38440980b0915b189f829c395 (diff) | |
download | external_llvm-888fae7b49f5d39f2371edb78566476396e30c75.zip external_llvm-888fae7b49f5d39f2371edb78566476396e30c75.tar.gz external_llvm-888fae7b49f5d39f2371edb78566476396e30c75.tar.bz2 |
Add front/back/erase to MapVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175449 91177308-0d34-0410-b5e6-96231b3b80d8
-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 f29681f..405fc43 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); + } }; } |