aboutsummaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-10-09 17:49:42 +0000
committerDouglas Gregor <dgregor@apple.com>2012-10-09 17:49:42 +0000
commit289c39965b1b799a22534d759fdf0a26302430d7 (patch)
tree7ce891d592ac7cb9b7e097c77a85bb0d8a14eeef /include/llvm
parent798290e744343f098c686537b2906f9b93741039 (diff)
Allow MapVector clients to specify the map and vector types, and add a
clear() method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165514 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/ADT/MapVector.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/include/llvm/ADT/MapVector.h b/include/llvm/ADT/MapVector.h
index bad207baa9..ffe1cd3eef 100644
--- a/include/llvm/ADT/MapVector.h
+++ b/include/llvm/ADT/MapVector.h
@@ -26,10 +26,10 @@ namespace llvm {
/// This class implements a map that also provides access to all stored values
/// in a deterministic order. The values are kept in a std::vector and the
/// mapping is done with DenseMap from Keys to indexes in that vector.
-template<typename KeyT, typename ValueT>
+template<typename KeyT, typename ValueT,
+ typename MapType = llvm::DenseMap<KeyT, unsigned>,
+ typename VectorType = std::vector<std::pair<KeyT, ValueT> >>
class MapVector {
- typedef llvm::DenseMap<KeyT, unsigned> MapType;
- typedef std::vector<std::pair<KeyT, ValueT> > VectorType;
typedef typename VectorType::size_type SizeType;
MapType Map;
@@ -63,6 +63,11 @@ public:
return Vector.empty();
}
+ void clear() {
+ Map.clear();
+ Vector.clear();
+ }
+
ValueT &operator[](const KeyT &Key) {
std::pair<KeyT, unsigned> Pair = std::make_pair(Key, 0);
std::pair<typename MapType::iterator, bool> Result = Map.insert(Pair);