aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2013-02-18 16:03:04 +0000
committerDouglas Gregor <dgregor@apple.com>2013-02-18 16:03:04 +0000
commit888fae7b49f5d39f2371edb78566476396e30c75 (patch)
treefdc7bbf601bd5bc4128d8891216b3497a7c522b2 /include
parente3111964a0902bc38440980b0915b189f829c395 (diff)
Add front/back/erase to MapVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/ADT/MapVector.h15
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);
+ }
};
}