aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanya Lattner <tonic@nondot.org>2010-03-12 00:10:21 +0000
committerTanya Lattner <tonic@nondot.org>2010-03-12 00:10:21 +0000
commit6fdd7771716fa2581cd4d73d574efe96bde74d51 (patch)
tree88e5b742f54b70bda00115b1ab9ae682c5e335be
parentc268488db7502d292f7857b7b7e910747a1b5c37 (diff)
downloadllvm-6fdd7771716fa2581cd4d73d574efe96bde74d51.zip
llvm-6fdd7771716fa2581cd4d73d574efe96bde74d51.tar.gz
llvm-6fdd7771716fa2581cd4d73d574efe96bde74d51.tar.bz2
Merge 97974 from mainline.
Iterator traits and swap. closes PR6548 and PR6549 llvm-svn: 98312
-rw-r--r--llvm/include/llvm/ADT/DenseMap.h7
-rw-r--r--llvm/include/llvm/ADT/DenseSet.h16
2 files changed, 23 insertions, 0 deletions
diff --git a/llvm/include/llvm/ADT/DenseMap.h b/llvm/include/llvm/ADT/DenseMap.h
index 7350906..393473b 100644
--- a/llvm/include/llvm/ADT/DenseMap.h
+++ b/llvm/include/llvm/ADT/DenseMap.h
@@ -192,6 +192,13 @@ public:
return true;
}
+ void swap(DenseMap& RHS) {
+ std::swap(NumBuckets, RHS.NumBuckets);
+ std::swap(Buckets, RHS.Buckets);
+ std::swap(NumEntries, RHS.NumEntries);
+ std::swap(NumTombstones, RHS.NumTombstones);
+ }
+
value_type& FindAndConstruct(const KeyT &Key) {
BucketT *TheBucket;
if (LookupBucketFor(Key, TheBucket))
diff --git a/llvm/include/llvm/ADT/DenseSet.h b/llvm/include/llvm/ADT/DenseSet.h
index 0898b968..9388338 100644
--- a/llvm/include/llvm/ADT/DenseSet.h
+++ b/llvm/include/llvm/ADT/DenseSet.h
@@ -45,6 +45,10 @@ public:
return TheMap.erase(V);
}
+ void swap(DenseSet& RHS) {
+ TheMap.swap(RHS.TheMap);
+ }
+
DenseSet &operator=(const DenseSet &RHS) {
TheMap = RHS.TheMap;
return *this;
@@ -55,6 +59,12 @@ public:
class Iterator {
typename MapTy::iterator I;
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; }
@@ -68,6 +78,12 @@ public:
class ConstIterator {
typename MapTy::const_iterator I;
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; }