llvm.org GIT mirror llvm / a3e5764
Made changes suggested by Chris; Renamed 'union' function to unionSetsWith git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6605 91177308-0d34-0410-b5e6-96231b3b80d8 Sumant Kowshik 17 years ago
2 changed file(s) with 14 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
1111 #define LLVM_SUPPORT_EQUIVALENCE_CLASSES_H
1212
1313 #include
14 #include
1514 #include
16 using std::map;
17 using std::set;
18 using std::vector;
1915
2016 template
2117 class EquivalenceClasses {
2218 // Maps each element to the element that is the leader of its
2319 // equivalence class.
24 map Elem2ECLeaderMap;
20 std::map Elem2ECLeaderMap;
2521
2622 // Make Element2 the leader of the union of classes Element1 and Element2
2723 // Element1 and Element2 are presumed to be leaders of their respective
2824 // equivalence classes.
2925 void attach(ElemTy Element1, ElemTy Element2) {
30 for (typename map::iterator ElemI =
26 for (typename std::map::iterator ElemI =
3127 Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
3228 ElemI != ElemE; ++ElemI) {
3329 if (ElemI->second == Element1)
5248 /// Attach the set with Element1 to the set with Element2 adding Element1 and
5349 /// Element2 to the set of equivalence classes if they are not there already.
5450 /// Implication: Make Element1 the element in the smaller set.
55 void unionElements(ElemTy Element1, ElemTy Element2) {
51 void unionSetsWith(ElemTy Element1, ElemTy Element2) {
5652 // If either Element1 or Element2 does not already exist, include it
5753 if (Elem2ECLeaderMap.find(Element1) == Elem2ECLeaderMap.end())
5854 Elem2ECLeaderMap[Element1] = Element1;
6460
6561 // Returns a vector containing all the elements in the equivalent class
6662 // including Element1
67 vector getEqClass(ElemTy Element1) {
68 vector EqClass;
63 std::vector getEqClass(ElemTy Element1) {
64 std::vector EqClass;
6965
7066 if (Elem2ECLeaderMap.find(EqClass) == Elem2ECLeaderMap.end())
7167 return EqClass;
7268
7369 ElemTy classLeader = Elem2ECLeaderMap[Element1];
7470
75 for (typename map::iterator ElemI =
71 for (typename std::map::iterator ElemI =
7672 Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
7773 ElemI != ElemE; ++ElemI) {
7874 if (ElemI->second == classLeader)
8379
8480 }
8581
86 map getLeaderMap() {
82 std::map& getLeaderMap() {
8783 return Elem2ECLeaderMap ;
8884 }
8985
1111 #define LLVM_SUPPORT_EQUIVALENCE_CLASSES_H
1212
1313 #include
14 #include
1514 #include
16 using std::map;
17 using std::set;
18 using std::vector;
1915
2016 template
2117 class EquivalenceClasses {
2218 // Maps each element to the element that is the leader of its
2319 // equivalence class.
24 map Elem2ECLeaderMap;
20 std::map Elem2ECLeaderMap;
2521
2622 // Make Element2 the leader of the union of classes Element1 and Element2
2723 // Element1 and Element2 are presumed to be leaders of their respective
2824 // equivalence classes.
2925 void attach(ElemTy Element1, ElemTy Element2) {
30 for (typename map::iterator ElemI =
26 for (typename std::map::iterator ElemI =
3127 Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
3228 ElemI != ElemE; ++ElemI) {
3329 if (ElemI->second == Element1)
5248 /// Attach the set with Element1 to the set with Element2 adding Element1 and
5349 /// Element2 to the set of equivalence classes if they are not there already.
5450 /// Implication: Make Element1 the element in the smaller set.
55 void unionElements(ElemTy Element1, ElemTy Element2) {
51 void unionSetsWith(ElemTy Element1, ElemTy Element2) {
5652 // If either Element1 or Element2 does not already exist, include it
5753 if (Elem2ECLeaderMap.find(Element1) == Elem2ECLeaderMap.end())
5854 Elem2ECLeaderMap[Element1] = Element1;
6460
6561 // Returns a vector containing all the elements in the equivalent class
6662 // including Element1
67 vector getEqClass(ElemTy Element1) {
68 vector EqClass;
63 std::vector getEqClass(ElemTy Element1) {
64 std::vector EqClass;
6965
7066 if (Elem2ECLeaderMap.find(EqClass) == Elem2ECLeaderMap.end())
7167 return EqClass;
7268
7369 ElemTy classLeader = Elem2ECLeaderMap[Element1];
7470
75 for (typename map::iterator ElemI =
71 for (typename std::map::iterator ElemI =
7672 Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
7773 ElemI != ElemE; ++ElemI) {
7874 if (ElemI->second == classLeader)
8379
8480 }
8581
86 map getLeaderMap() {
82 std::map& getLeaderMap() {
8783 return Elem2ECLeaderMap ;
8884 }
8985