[ADT] Remove ImmutableSet::foreach and ImmutableMap::foreach (NFC)
These functions seem to be unused for at least 1 year.
This commit is contained in:
@@ -140,44 +140,7 @@ public:
|
||||
|
||||
bool isEmpty() const { return !Root; }
|
||||
|
||||
//===--------------------------------------------------===//
|
||||
// Foreach - A limited form of map iteration.
|
||||
//===--------------------------------------------------===//
|
||||
|
||||
private:
|
||||
template <typename Callback>
|
||||
struct CBWrapper {
|
||||
Callback C;
|
||||
|
||||
void operator()(value_type_ref V) { C(V.first,V.second); }
|
||||
};
|
||||
|
||||
template <typename Callback>
|
||||
struct CBWrapperRef {
|
||||
Callback &C;
|
||||
|
||||
CBWrapperRef(Callback& c) : C(c) {}
|
||||
|
||||
void operator()(value_type_ref V) { C(V.first,V.second); }
|
||||
};
|
||||
|
||||
public:
|
||||
template <typename Callback>
|
||||
void foreach(Callback& C) {
|
||||
if (Root) {
|
||||
CBWrapperRef<Callback> CB(C);
|
||||
Root->foreach(CB);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Callback>
|
||||
void foreach() {
|
||||
if (Root) {
|
||||
CBWrapper<Callback> CB;
|
||||
Root->foreach(CB);
|
||||
}
|
||||
}
|
||||
|
||||
//===--------------------------------------------------===//
|
||||
// For testing.
|
||||
//===--------------------------------------------------===//
|
||||
|
||||
@@ -169,20 +169,6 @@ public:
|
||||
/// is logarithmic in the size of the tree.
|
||||
bool contains(key_type_ref K) { return (bool) find(K); }
|
||||
|
||||
/// foreach - A member template the accepts invokes operator() on a functor
|
||||
/// object (specified by Callback) for every node/subtree in the tree.
|
||||
/// Nodes are visited using an inorder traversal.
|
||||
template <typename Callback>
|
||||
void foreach(Callback& C) {
|
||||
if (ImutAVLTree* L = getLeft())
|
||||
L->foreach(C);
|
||||
|
||||
C(value);
|
||||
|
||||
if (ImutAVLTree* R = getRight())
|
||||
R->foreach(C);
|
||||
}
|
||||
|
||||
/// validateTree - A utility method that checks that the balancing and
|
||||
/// ordering invariants of the tree are satisfied. It is a recursive
|
||||
/// method that returns the height of the tree, which is then consumed
|
||||
@@ -1063,12 +1049,6 @@ public:
|
||||
/// This method runs in constant time.
|
||||
bool isSingleton() const { return getHeight() == 1; }
|
||||
|
||||
template <typename Callback>
|
||||
void foreach(Callback& C) { if (Root) Root->foreach(C); }
|
||||
|
||||
template <typename Callback>
|
||||
void foreach() { if (Root) { Callback C; Root->foreach(C); } }
|
||||
|
||||
//===--------------------------------------------------===//
|
||||
// Iterators.
|
||||
//===--------------------------------------------------===//
|
||||
|
||||
@@ -136,41 +136,6 @@ TEST_F(ImmutableSetTest, RemoveIntSetTest) {
|
||||
EXPECT_TRUE(S4.contains(5));
|
||||
}
|
||||
|
||||
TEST_F(ImmutableSetTest, CallbackCharSetTest) {
|
||||
ImmutableSet<char>::Factory f;
|
||||
ImmutableSet<char> S = f.getEmptySet();
|
||||
|
||||
ImmutableSet<char> S2 = f.add(f.add(f.add(S, 'a'), 'e'), 'i');
|
||||
ImmutableSet<char> S3 = f.add(f.add(S2, 'o'), 'u');
|
||||
|
||||
S3.foreach<MyIter>();
|
||||
|
||||
ASSERT_STREQ("aeiou", buffer);
|
||||
}
|
||||
|
||||
TEST_F(ImmutableSetTest, Callback2CharSetTest) {
|
||||
ImmutableSet<char>::Factory f;
|
||||
ImmutableSet<char> S = f.getEmptySet();
|
||||
|
||||
ImmutableSet<char> S2 = f.add(f.add(f.add(S, 'b'), 'c'), 'd');
|
||||
ImmutableSet<char> S3 = f.add(f.add(f.add(S2, 'f'), 'g'), 'h');
|
||||
|
||||
MyIter obj;
|
||||
S3.foreach<MyIter>(obj);
|
||||
ASSERT_STREQ("bcdfgh", buffer);
|
||||
ASSERT_EQ(6, obj.counter);
|
||||
|
||||
MyIter obj2;
|
||||
S2.foreach<MyIter>(obj2);
|
||||
ASSERT_STREQ("bcd", buffer);
|
||||
ASSERT_EQ(3, obj2.counter);
|
||||
|
||||
MyIter obj3;
|
||||
S.foreach<MyIter>(obj);
|
||||
ASSERT_STREQ("", buffer);
|
||||
ASSERT_EQ(0, obj3.counter);
|
||||
}
|
||||
|
||||
TEST_F(ImmutableSetTest, IterLongSetTest) {
|
||||
ImmutableSet<long>::Factory f;
|
||||
ImmutableSet<long> S = f.getEmptySet();
|
||||
|
||||
Reference in New Issue
Block a user