diff --git a/llvm/include/llvm/ADT/ImmutableMap.h b/llvm/include/llvm/ADT/ImmutableMap.h index cf6fb870897aef..f0e898cafaf94b 100644 --- a/llvm/include/llvm/ADT/ImmutableMap.h +++ b/llvm/include/llvm/ADT/ImmutableMap.h @@ -140,44 +140,7 @@ class ImmutableMap { bool isEmpty() const { return !Root; } - //===--------------------------------------------------===// - // Foreach - A limited form of map iteration. - //===--------------------------------------------------===// - -private: - template - struct CBWrapper { - Callback C; - - void operator()(value_type_ref V) { C(V.first,V.second); } - }; - - template - struct CBWrapperRef { - Callback &C; - - CBWrapperRef(Callback& c) : C(c) {} - - void operator()(value_type_ref V) { C(V.first,V.second); } - }; - public: - template - void foreach(Callback& C) { - if (Root) { - CBWrapperRef CB(C); - Root->foreach(CB); - } - } - - template - void foreach() { - if (Root) { - CBWrapper CB; - Root->foreach(CB); - } - } - //===--------------------------------------------------===// // For testing. //===--------------------------------------------------===// diff --git a/llvm/include/llvm/ADT/ImmutableSet.h b/llvm/include/llvm/ADT/ImmutableSet.h index 48b253d3b75e79..8cef5acbafaaf5 100644 --- a/llvm/include/llvm/ADT/ImmutableSet.h +++ b/llvm/include/llvm/ADT/ImmutableSet.h @@ -169,20 +169,6 @@ class ImutAVLTree { /// 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 - 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 @@ class ImmutableSet { /// This method runs in constant time. bool isSingleton() const { return getHeight() == 1; } - template - void foreach(Callback& C) { if (Root) Root->foreach(C); } - - template - void foreach() { if (Root) { Callback C; Root->foreach(C); } } - //===--------------------------------------------------===// // Iterators. //===--------------------------------------------------===// diff --git a/llvm/unittests/ADT/ImmutableSetTest.cpp b/llvm/unittests/ADT/ImmutableSetTest.cpp index e23cd2b3d1a818..c0bde4c4d680bd 100644 --- a/llvm/unittests/ADT/ImmutableSetTest.cpp +++ b/llvm/unittests/ADT/ImmutableSetTest.cpp @@ -136,41 +136,6 @@ TEST_F(ImmutableSetTest, RemoveIntSetTest) { EXPECT_TRUE(S4.contains(5)); } -TEST_F(ImmutableSetTest, CallbackCharSetTest) { - ImmutableSet::Factory f; - ImmutableSet S = f.getEmptySet(); - - ImmutableSet S2 = f.add(f.add(f.add(S, 'a'), 'e'), 'i'); - ImmutableSet S3 = f.add(f.add(S2, 'o'), 'u'); - - S3.foreach(); - - ASSERT_STREQ("aeiou", buffer); -} - -TEST_F(ImmutableSetTest, Callback2CharSetTest) { - ImmutableSet::Factory f; - ImmutableSet S = f.getEmptySet(); - - ImmutableSet S2 = f.add(f.add(f.add(S, 'b'), 'c'), 'd'); - ImmutableSet S3 = f.add(f.add(f.add(S2, 'f'), 'g'), 'h'); - - MyIter obj; - S3.foreach(obj); - ASSERT_STREQ("bcdfgh", buffer); - ASSERT_EQ(6, obj.counter); - - MyIter obj2; - S2.foreach(obj2); - ASSERT_STREQ("bcd", buffer); - ASSERT_EQ(3, obj2.counter); - - MyIter obj3; - S.foreach(obj); - ASSERT_STREQ("", buffer); - ASSERT_EQ(0, obj3.counter); -} - TEST_F(ImmutableSetTest, IterLongSetTest) { ImmutableSet::Factory f; ImmutableSet S = f.getEmptySet();