mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-09 10:31:14 +00:00
Allow MapVector clients to specify the map and vector types, and add a
clear() method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165514 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
798290e744
commit
289c39965b
@ -26,10 +26,10 @@ namespace llvm {
|
||||
/// This class implements a map that also provides access to all stored values
|
||||
/// in a deterministic order. The values are kept in a std::vector and the
|
||||
/// mapping is done with DenseMap from Keys to indexes in that vector.
|
||||
template<typename KeyT, typename ValueT>
|
||||
template<typename KeyT, typename ValueT,
|
||||
typename MapType = llvm::DenseMap<KeyT, unsigned>,
|
||||
typename VectorType = std::vector<std::pair<KeyT, ValueT> >>
|
||||
class MapVector {
|
||||
typedef llvm::DenseMap<KeyT, unsigned> MapType;
|
||||
typedef std::vector<std::pair<KeyT, ValueT> > VectorType;
|
||||
typedef typename VectorType::size_type SizeType;
|
||||
|
||||
MapType Map;
|
||||
@ -63,6 +63,11 @@ public:
|
||||
return Vector.empty();
|
||||
}
|
||||
|
||||
void clear() {
|
||||
Map.clear();
|
||||
Vector.clear();
|
||||
}
|
||||
|
||||
ValueT &operator[](const KeyT &Key) {
|
||||
std::pair<KeyT, unsigned> Pair = std::make_pair(Key, 0);
|
||||
std::pair<typename MapType::iterator, bool> Result = Map.insert(Pair);
|
||||
|
Loading…
Reference in New Issue
Block a user