[llvm] r175449 - Add front/back/erase to MapVector.
Douglas Gregor
dgregor at apple.com
Mon Feb 18 08:03:04 PST 2013
Author: dgregor
Date: Mon Feb 18 10:03:04 2013
New Revision: 175449
URL: http://llvm.org/viewvc/llvm-project?rev=175449&view=rev
Log:
Add front/back/erase to MapVector.
Modified:
llvm/trunk/include/llvm/ADT/MapVector.h
Modified: llvm/trunk/include/llvm/ADT/MapVector.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/MapVector.h?rev=175449&r1=175448&r2=175449&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/MapVector.h (original)
+++ llvm/trunk/include/llvm/ADT/MapVector.h Mon Feb 18 10:03:04 2013
@@ -64,6 +64,11 @@ public:
return Vector.empty();
}
+ std::pair<KeyT, ValueT> &front() { return Vector.front(); }
+ const std::pair<KeyT, ValueT> &front() const { return Vector.front(); }
+ std::pair<KeyT, ValueT> &back() { return Vector.back(); }
+ const std::pair<KeyT, ValueT> &back() const { return Vector.back(); }
+
void clear() {
Map.clear();
Vector.clear();
@@ -113,6 +118,16 @@ public:
return Pos == Map.end()? Vector.end() :
(Vector.begin() + Pos->second);
}
+
+ /// \brief Erase entry with the given key.
+ void erase(const KeyT &key) {
+ typename MapType::iterator Pos = Map.find(key);
+ if (Pos == Map.end())
+ return;
+
+ Vector.erase(Vector.begin() + Pos->second);
+ Map.erase(Pos);
+ }
};
}
More information about the llvm-commits
mailing list