summaryrefslogtreecommitdiff
path: root/include/llvm/ADT/ScopedHashTable.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/ADT/ScopedHashTable.h')
-rw-r--r--include/llvm/ADT/ScopedHashTable.h40
1 files changed, 20 insertions, 20 deletions
diff --git a/include/llvm/ADT/ScopedHashTable.h b/include/llvm/ADT/ScopedHashTable.h
index 5abe76c12259..4af3d6d37e33 100644
--- a/include/llvm/ADT/ScopedHashTable.h
+++ b/include/llvm/ADT/ScopedHashTable.h
@@ -1,4 +1,4 @@
-//===- ScopedHashTable.h - A simple scoped hash table ---------------------===//
+//===- ScopedHashTable.h - A simple scoped hash table -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -47,8 +47,8 @@ class ScopedHashTableVal {
K Key;
V Val;
ScopedHashTableVal(const K &key, const V &val) : Key(key), Val(val) {}
-public:
+public:
const K &getKey() const { return Key; }
const V &getValue() const { return Val; }
V &getValue() { return Val; }
@@ -56,7 +56,7 @@ public:
ScopedHashTableVal *getNextForKey() { return NextForKey; }
const ScopedHashTableVal *getNextForKey() const { return NextForKey; }
ScopedHashTableVal *getNextInScope() { return NextInScope; }
-
+
template <typename AllocatorTy>
static ScopedHashTableVal *Create(ScopedHashTableVal *nextInScope,
ScopedHashTableVal *nextForKey,
@@ -66,12 +66,11 @@ public:
// Set up the value.
new (New) ScopedHashTableVal(key, val);
New->NextInScope = nextInScope;
- New->NextForKey = nextForKey;
+ New->NextForKey = nextForKey;
return New;
}
-
- template <typename AllocatorTy>
- void Destroy(AllocatorTy &Allocator) {
+
+ template <typename AllocatorTy> void Destroy(AllocatorTy &Allocator) {
// Free memory referenced by the item.
this->~ScopedHashTableVal();
Allocator.Deallocate(this);
@@ -90,15 +89,16 @@ class ScopedHashTableScope {
/// LastValInScope - This is the last value that was inserted for this scope
/// or null if none have been inserted yet.
ScopedHashTableVal<K, V> *LastValInScope;
- void operator=(ScopedHashTableScope&) = delete;
- ScopedHashTableScope(ScopedHashTableScope&) = delete;
+ void operator=(ScopedHashTableScope &) = delete;
+ ScopedHashTableScope(ScopedHashTableScope &) = delete;
+
public:
ScopedHashTableScope(ScopedHashTable<K, V, KInfo, AllocatorTy> &HT);
~ScopedHashTableScope();
ScopedHashTableScope *getParentScope() { return PrevScope; }
const ScopedHashTableScope *getParentScope() const { return PrevScope; }
-
+
private:
friend class ScopedHashTable<K, V, KInfo, AllocatorTy>;
ScopedHashTableVal<K, V> *getLastValInScope() {
@@ -109,10 +109,10 @@ private:
}
};
-
-template <typename K, typename V, typename KInfo = DenseMapInfo<K> >
+template <typename K, typename V, typename KInfo = DenseMapInfo<K>>
class ScopedHashTableIterator {
ScopedHashTableVal<K, V> *Node;
+
public:
ScopedHashTableIterator(ScopedHashTableVal<K, V> *node) : Node(node) {}
@@ -141,7 +141,6 @@ public:
}
};
-
template <typename K, typename V, typename KInfo, typename AllocatorTy>
class ScopedHashTable {
public:
@@ -149,23 +148,24 @@ public:
/// to the name of the scope for this hash table.
typedef ScopedHashTableScope<K, V, KInfo, AllocatorTy> ScopeTy;
typedef unsigned size_type;
+
private:
typedef ScopedHashTableVal<K, V> ValTy;
DenseMap<K, ValTy*, KInfo> TopLevelMap;
ScopeTy *CurScope;
-
+
AllocatorTy Allocator;
-
- ScopedHashTable(const ScopedHashTable&); // NOT YET IMPLEMENTED
- void operator=(const ScopedHashTable&); // NOT YET IMPLEMENTED
+
+ ScopedHashTable(const ScopedHashTable &); // NOT YET IMPLEMENTED
+ void operator=(const ScopedHashTable &); // NOT YET IMPLEMENTED
friend class ScopedHashTableScope<K, V, KInfo, AllocatorTy>;
+
public:
ScopedHashTable() : CurScope(nullptr) {}
ScopedHashTable(AllocatorTy A) : CurScope(0), Allocator(A) {}
~ScopedHashTable() {
assert(!CurScope && TopLevelMap.empty() && "Scope imbalance!");
}
-
/// Access to the allocator.
AllocatorTy &getAllocator() { return Allocator; }
@@ -180,7 +180,7 @@ public:
typename DenseMap<K, ValTy*, KInfo>::iterator I = TopLevelMap.find(Key);
if (I != TopLevelMap.end())
return I->second->getValue();
-
+
return V();
}
@@ -198,7 +198,7 @@ public:
if (I == TopLevelMap.end()) return end();
return iterator(I->second);
}
-
+
ScopeTy *getCurScope() { return CurScope; }
const ScopeTy *getCurScope() const { return CurScope; }