Extend StringRef's edit-distance algorithm to permit an upper bound on the allowed...
[oota-llvm.git] / include / llvm / ADT / DenseSet.h
index 89f55caa95475c64c054bc1f9cd7bd49af4cfc0e..00bcf64a2fc7c246514b33753f05a308fb363419 100644 (file)
@@ -41,8 +41,12 @@ public:
     return TheMap.count(V);
   }
 
-  void erase(const ValueT &V) {
-    TheMap.erase(V);
+  bool erase(const ValueT &V) {
+    return TheMap.erase(V);
+  }
+
+  void swap(DenseSet& RHS) {
+    TheMap.swap(RHS.TheMap);
   }
 
   DenseSet &operator=(const DenseSet &RHS) {
@@ -54,7 +58,14 @@ public:
 
   class Iterator {
     typename MapTy::iterator I;
+    friend class DenseSet;
   public:
+    typedef typename MapTy::iterator::difference_type difference_type;
+    typedef ValueT value_type;
+    typedef value_type *pointer;
+    typedef value_type &reference;
+    typedef std::forward_iterator_tag iterator_category;
+
     Iterator(const typename MapTy::iterator &i) : I(i) {}
 
     ValueT& operator*() { return I->first; }
@@ -67,7 +78,14 @@ public:
 
   class ConstIterator {
     typename MapTy::const_iterator I;
+    friend class DenseSet;
   public:
+    typedef typename MapTy::const_iterator::difference_type difference_type;
+    typedef ValueT value_type;
+    typedef value_type *pointer;
+    typedef value_type &reference;
+    typedef std::forward_iterator_tag iterator_category;
+
     ConstIterator(const typename MapTy::const_iterator &i) : I(i) {}
 
     const ValueT& operator*() { return I->first; }
@@ -87,6 +105,10 @@ public:
   const_iterator begin() const { return ConstIterator(TheMap.begin()); }
   const_iterator end() const { return ConstIterator(TheMap.end()); }
 
+  iterator find(const ValueT &V) { return Iterator(TheMap.find(V)); }
+  void erase(Iterator I) { return TheMap.erase(I.I); }
+  void erase(ConstIterator CI) { return TheMap.erase(CI.I); }
+
   std::pair<iterator, bool> insert(const ValueT &V) {
     return TheMap.insert(std::make_pair(V, 0));
   }