Skip to content

Commit c59a1e5

Browse files
committed
[gardening] Standardize indentation in BlotMapVector.h
Part of the file was following LLVM style for class indentation and other parts were not. This commit makes it consistent.
1 parent 2007bad commit c59a1e5

File tree

1 file changed

+102
-102
lines changed

1 file changed

+102
-102
lines changed

include/swift/Basic/BlotMapVector.h

Lines changed: 102 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -31,113 +31,113 @@ template <typename KeyT, typename ValueT,
3131
typename MapT = llvm::DenseMap<KeyT, size_t>,
3232
typename VectorT = std::vector<Optional<std::pair<KeyT, ValueT>>>>
3333
class BlotMapVector {
34-
/// Map keys to indices in Vector.
35-
MapT Map;
34+
/// Map keys to indices in Vector.
35+
MapT Map;
3636

37-
/// Keys and values.
38-
VectorT Vector;
37+
/// Keys and values.
38+
VectorT Vector;
3939

40-
public:
41-
using iterator = typename VectorT::iterator;
42-
using const_iterator = typename VectorT::const_iterator;
43-
using key_type = KeyT;
44-
using mapped_type = ValueT;
45-
46-
iterator begin() { return Vector.begin(); }
47-
iterator end() { return Vector.end(); }
48-
const_iterator begin() const { return Vector.begin(); }
49-
const_iterator end() const { return Vector.end(); }
50-
51-
iterator_range<iterator> getItems() {
52-
return swift::make_range(begin(), end());
53-
}
54-
iterator_range<const_iterator> getItems() const {
55-
return swift::make_range(begin(), end());
56-
}
57-
58-
ValueT &operator[](const KeyT &Arg) {
59-
auto Pair = Map.insert(std::make_pair(Arg, size_t(0)));
60-
if (Pair.second) {
61-
size_t Num = Vector.size();
62-
Pair.first->second = Num;
63-
Vector.push_back({std::make_pair(Arg, ValueT())});
64-
return (*Vector[Num]).second;
65-
}
66-
return Vector[Pair.first->second].getValue().second;
67-
}
68-
69-
std::pair<iterator, bool>
70-
insert(const std::pair<KeyT, ValueT> &InsertPair) {
71-
auto Pair = Map.insert(std::make_pair(InsertPair.first, size_t(0)));
72-
if (Pair.second) {
73-
size_t Num = Vector.size();
74-
Pair.first->second = Num;
75-
Vector.push_back(InsertPair);
76-
return std::make_pair(Vector.begin() + Num, true);
77-
}
78-
return std::make_pair(Vector.begin() + Pair.first->second, false);
79-
}
80-
81-
iterator find(const KeyT &Key) {
82-
typename MapT::iterator It = Map.find(Key);
83-
if (It == Map.end()) return Vector.end();
84-
auto Iter = Vector.begin() + It->second;
85-
if (!Iter->hasValue())
86-
return Vector.end();
87-
return Iter;
88-
}
89-
90-
const_iterator find(const KeyT &Key) const {
91-
return const_cast<BlotMapVector &>(*this).find(Key);
92-
}
93-
94-
/// Eliminate the element at `Key`. Instead of removing the element from the
95-
/// vector, just zero out the key in the vector. This leaves iterators
96-
/// intact, but clients must be prepared for zeroed-out keys when iterating.
97-
///
98-
/// Return true if the element was found and erased.
99-
bool erase(const KeyT &Key) {
100-
typename MapT::iterator It = Map.find(Key);
101-
if (It == Map.end())
102-
return false;
103-
Vector[It->second] = None;
104-
Map.erase(It);
105-
return true;
40+
public:
41+
using iterator = typename VectorT::iterator;
42+
using const_iterator = typename VectorT::const_iterator;
43+
using key_type = KeyT;
44+
using mapped_type = ValueT;
45+
46+
iterator begin() { return Vector.begin(); }
47+
iterator end() { return Vector.end(); }
48+
const_iterator begin() const { return Vector.begin(); }
49+
const_iterator end() const { return Vector.end(); }
50+
51+
iterator_range<iterator> getItems() {
52+
return swift::make_range(begin(), end());
53+
}
54+
iterator_range<const_iterator> getItems() const {
55+
return swift::make_range(begin(), end());
56+
}
57+
58+
ValueT &operator[](const KeyT &Arg) {
59+
auto Pair = Map.insert(std::make_pair(Arg, size_t(0)));
60+
if (Pair.second) {
61+
size_t Num = Vector.size();
62+
Pair.first->second = Num;
63+
Vector.push_back({std::make_pair(Arg, ValueT())});
64+
return (*Vector[Num]).second;
10665
}
107-
108-
/// Eliminate the element at the given iterator. Instead of removing the
109-
/// element from the vector, just zero out the key in the vector. This
110-
/// leaves iterators intact, but clients must be prepared for zeroed-out
111-
/// keys when iterating.
112-
void erase(iterator I) { erase((*I)->first); }
113-
114-
void clear() {
115-
Map.clear();
116-
Vector.clear();
66+
return Vector[Pair.first->second].getValue().second;
67+
}
68+
69+
std::pair<iterator, bool> insert(const std::pair<KeyT, ValueT> &InsertPair) {
70+
auto Pair = Map.insert(std::make_pair(InsertPair.first, size_t(0)));
71+
if (Pair.second) {
72+
size_t Num = Vector.size();
73+
Pair.first->second = Num;
74+
Vector.push_back(InsertPair);
75+
return std::make_pair(Vector.begin() + Num, true);
11776
}
77+
return std::make_pair(Vector.begin() + Pair.first->second, false);
78+
}
79+
80+
iterator find(const KeyT &Key) {
81+
typename MapT::iterator It = Map.find(Key);
82+
if (It == Map.end())
83+
return Vector.end();
84+
auto Iter = Vector.begin() + It->second;
85+
if (!Iter->hasValue())
86+
return Vector.end();
87+
return Iter;
88+
}
89+
90+
const_iterator find(const KeyT &Key) const {
91+
return const_cast<BlotMapVector &>(*this).find(Key);
92+
}
93+
94+
/// Eliminate the element at `Key`. Instead of removing the element from the
95+
/// vector, just zero out the key in the vector. This leaves iterators
96+
/// intact, but clients must be prepared for zeroed-out keys when iterating.
97+
///
98+
/// Return true if the element was found and erased.
99+
bool erase(const KeyT &Key) {
100+
typename MapT::iterator It = Map.find(Key);
101+
if (It == Map.end())
102+
return false;
103+
Vector[It->second] = None;
104+
Map.erase(It);
105+
return true;
106+
}
107+
108+
/// Eliminate the element at the given iterator. Instead of removing the
109+
/// element from the vector, just zero out the key in the vector. This
110+
/// leaves iterators intact, but clients must be prepared for zeroed-out
111+
/// keys when iterating.
112+
void erase(iterator I) { erase((*I)->first); }
113+
114+
void clear() {
115+
Map.clear();
116+
Vector.clear();
117+
}
118+
119+
unsigned size() const { return Map.size(); }
120+
121+
ValueT lookup(const KeyT &Val) const {
122+
auto Iter = Map.find(Val);
123+
if (Iter == Map.end())
124+
return ValueT();
125+
auto &P = Vector[Iter->second];
126+
if (!P.hasValue())
127+
return ValueT();
128+
return P->second;
129+
}
130+
131+
size_t count(const KeyT &Val) const { return Map.count(Val); }
132+
133+
bool empty() const { return Map.empty(); }
134+
};
118135

119-
unsigned size() const { return Map.size(); }
120-
121-
ValueT lookup(const KeyT &Val) const {
122-
auto Iter = Map.find(Val);
123-
if (Iter == Map.end())
124-
return ValueT();
125-
auto &P = Vector[Iter->second];
126-
if (!P.hasValue())
127-
return ValueT();
128-
return P->second;
129-
}
130-
131-
size_t count(const KeyT &Val) const { return Map.count(Val); }
132-
133-
bool empty() const { return Map.empty(); }
134-
};
135-
136-
template <typename KeyT, typename ValueT, unsigned N,
137-
typename MapT = llvm::SmallDenseMap<KeyT, size_t, N>,
138-
typename VectorT =
139-
llvm::SmallVector<Optional<std::pair<KeyT, ValueT>>, N>>
140-
class SmallBlotMapVector : public BlotMapVector<KeyT, ValueT, MapT, VectorT> {
136+
template <typename KeyT, typename ValueT, unsigned N,
137+
typename MapT = llvm::SmallDenseMap<KeyT, size_t, N>,
138+
typename VectorT =
139+
llvm::SmallVector<Optional<std::pair<KeyT, ValueT>>, N>>
140+
class SmallBlotMapVector : public BlotMapVector<KeyT, ValueT, MapT, VectorT> {
141141
public:
142142
SmallBlotMapVector() {}
143143
};

0 commit comments

Comments
 (0)