//
// The LLVM Compiler Infrastructure
//
-// This file was developed by Chris Lattner and is distributed under
-// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
unsigned NumEntries;
unsigned NumTombstones;
public:
+ typedef BucketT value_type;
+
DenseMap(const DenseMap& other) {
NumBuckets = 0;
CopyFrom(other);
++NumTombstones;
return true;
}
-
- ValueT &operator[](const KeyT &Key) {
+
+ value_type& FindAndConstruct(const KeyT &Key) {
BucketT *TheBucket;
if (LookupBucketFor(Key, TheBucket))
- return TheBucket->second;
-
- return InsertIntoBucket(Key, ValueT(), TheBucket)->second;
+ return *TheBucket;
+
+ return *InsertIntoBucket(Key, ValueT(), TheBucket);
+ }
+
+ ValueT &operator[](const KeyT &Key) {
+ return FindAndConstruct(Key).second;
}
DenseMap& operator=(const DenseMap& other) {