mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-21 02:24:22 +00: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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182487 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -102,6 +102,13 @@ public:
|
|||||||
|
|
||||||
bool empty() const { return NumItems == 0; }
|
bool empty() const { return NumItems == 0; }
|
||||||
unsigned size() const { return NumItems; }
|
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
|
/// StringMapEntry - This is used to represent one value that is inserted into
|
||||||
@ -409,6 +416,8 @@ protected:
|
|||||||
public:
|
public:
|
||||||
typedef StringMapEntry<ValueTy> value_type;
|
typedef StringMapEntry<ValueTy> value_type;
|
||||||
|
|
||||||
|
StringMapConstIterator() : Ptr(0) { }
|
||||||
|
|
||||||
explicit StringMapConstIterator(StringMapEntryBase **Bucket,
|
explicit StringMapConstIterator(StringMapEntryBase **Bucket,
|
||||||
bool NoAdvance = false)
|
bool NoAdvance = false)
|
||||||
: Ptr(Bucket) {
|
: Ptr(Bucket) {
|
||||||
@ -448,6 +457,7 @@ private:
|
|||||||
template<typename ValueTy>
|
template<typename ValueTy>
|
||||||
class StringMapIterator : public StringMapConstIterator<ValueTy> {
|
class StringMapIterator : public StringMapConstIterator<ValueTy> {
|
||||||
public:
|
public:
|
||||||
|
StringMapIterator() : StringMapConstIterator() {}
|
||||||
explicit StringMapIterator(StringMapEntryBase **Bucket,
|
explicit StringMapIterator(StringMapEntryBase **Bucket,
|
||||||
bool NoAdvance = false)
|
bool NoAdvance = false)
|
||||||
: StringMapConstIterator<ValueTy>(Bucket, NoAdvance) {
|
: StringMapConstIterator<ValueTy>(Bucket, NoAdvance) {
|
||||||
|
Reference in New Issue
Block a user