1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[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

llvm-svn: 182487
This commit is contained in:
Reid Kleckner 2013-05-22 17:10:11 +00:00
parent dced131e7e
commit d552e7cd95

View File

@ -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) {