[llvm-commits] [llvm] r97974 - in /llvm/trunk/include/llvm/ADT: DenseMap.h DenseSet.h
alenhar2 at llvm.org
alenhar2 at llvm.org
Mon Mar 8 12:45:53 PST 2010
Author: alenhar2
Date: Mon Mar 8 14:45:52 2010
New Revision: 97974
URL: http://llvm.org/viewvc/llvm-project?rev=97974&view=rev
Log:
Iterator traits and swap. closes PR6548 and PR6549
Modified:
llvm/trunk/include/llvm/ADT/DenseMap.h
llvm/trunk/include/llvm/ADT/DenseSet.h
Modified: llvm/trunk/include/llvm/ADT/DenseMap.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseMap.h?rev=97974&r1=97973&r2=97974&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseMap.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseMap.h Mon Mar 8 14:45:52 2010
@@ -192,6 +192,13 @@
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))
Modified: llvm/trunk/include/llvm/ADT/DenseSet.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/DenseSet.h?rev=97974&r1=97973&r2=97974&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/DenseSet.h (original)
+++ llvm/trunk/include/llvm/ADT/DenseSet.h Mon Mar 8 14:45:52 2010
@@ -45,6 +45,10 @@
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 @@
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 @@
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; }
More information about the llvm-commits
mailing list