diff options
author | Reid Kleckner <reid@kleckner.net> | 2013-05-22 17:10:11 +0000 |
---|---|---|
committer | Reid Kleckner <reid@kleckner.net> | 2013-05-22 17:10:11 +0000 |
commit | 284ffa3863bc58f18a3eb879e49e05fdbe792413 (patch) | |
tree | 5cdc10f79c9531cbea63d09271172d97280aeda5 | |
parent | 60ef6c9295844038406c6083b67ea24b3646f2dd (diff) | |
download | external_llvm-284ffa3863bc58f18a3eb879e49e05fdbe792413.zip external_llvm-284ffa3863bc58f18a3eb879e49e05fdbe792413.tar.gz external_llvm-284ffa3863bc58f18a3eb879e49e05fdbe792413.tar.bz2 |
[Support] Add StringMap::swap() and a default ctor for iterators
This makes StringMap<> more compatible with std::map<std::string, ...>.
Differential Revision: http://llvm-reviews.chandlerc.com/D842
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182487 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/StringMap.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index d01437b..2e07268 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -102,6 +102,13 @@ public: bool empty() const { return NumItems == 0; } unsigned size() const { return NumItems; } + + void swap(StringMapImpl &Other) { + std::swap(TheTable, Other.TheTable); + std::swap(NumBuckets, Other.NumBuckets); + std::swap(NumItems, Other.NumItems); + std::swap(NumTombstones, Other.NumTombstones); + } }; /// StringMapEntry - This is used to represent one value that is inserted into @@ -409,6 +416,8 @@ protected: public: typedef StringMapEntry<ValueTy> value_type; + StringMapConstIterator() : Ptr(0) { } + explicit StringMapConstIterator(StringMapEntryBase **Bucket, bool NoAdvance = false) : Ptr(Bucket) { @@ -448,6 +457,7 @@ private: template<typename ValueTy> class StringMapIterator : public StringMapConstIterator<ValueTy> { public: + StringMapIterator() : StringMapConstIterator() {} explicit StringMapIterator(StringMapEntryBase **Bucket, bool NoAdvance = false) : StringMapConstIterator<ValueTy>(Bucket, NoAdvance) { |