[llvm-commits] [llvm] r165514 - /llvm/trunk/include/llvm/ADT/MapVector.h

Douglas Gregor dgregor at apple.com
Tue Oct 9 10:49:43 PDT 2012


Author: dgregor
Date: Tue Oct  9 12:49:42 2012
New Revision: 165514

URL: http://llvm.org/viewvc/llvm-project?rev=165514&view=rev
Log:
Allow MapVector clients to specify the map and vector types, and add a
clear() method.

Modified:
    llvm/trunk/include/llvm/ADT/MapVector.h

Modified: llvm/trunk/include/llvm/ADT/MapVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/MapVector.h?rev=165514&r1=165513&r2=165514&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/MapVector.h (original)
+++ llvm/trunk/include/llvm/ADT/MapVector.h Tue Oct  9 12:49:42 2012
@@ -26,10 +26,10 @@
 /// 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 @@
     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);





More information about the llvm-commits mailing list