[PATCH] [Support] Add StringMap::swap() and a default ctor for iterators

Chris Lattner clattner at apple.com
Wed May 22 09:45:30 PDT 2013


On May 22, 2013, at 6:42 AM, Reid Kleckner <rnk at google.com> wrote:

> This makes StringMap<> more compatible with std::map<std::string, ...>.
> 
> http://llvm-reviews.chandlerc.com/D842

LGTM,

-Chris

> 
> Files:
>  include/llvm/ADT/StringMap.h
> 
> Index: include/llvm/ADT/StringMap.h
> ===================================================================
> --- include/llvm/ADT/StringMap.h
> +++ include/llvm/ADT/StringMap.h
> @@ -102,6 +102,13 @@
> 
>   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 @@
> public:
>   typedef StringMapEntry<ValueTy> value_type;
> 
> +  StringMapConstIterator() : Ptr(0) { }
> +
>   explicit StringMapConstIterator(StringMapEntryBase **Bucket,
>                                   bool NoAdvance = false)
>   : Ptr(Bucket) {
> @@ -448,6 +457,7 @@
> template<typename ValueTy>
> class StringMapIterator : public StringMapConstIterator<ValueTy> {
> public:
> +  StringMapIterator() : StringMapConstIterator() {}
>   explicit StringMapIterator(StringMapEntryBase **Bucket,
>                              bool NoAdvance = false)
>     : StringMapConstIterator<ValueTy>(Bucket, NoAdvance) {
> <D842.1.patch>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list