mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-12 17:32:19 +00:00
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
This commit is contained in:
parent
40f5d70db4
commit
a3e5764984
@ -12,23 +12,19 @@
|
|||||||
#define LLVM_SUPPORT_EQUIVALENCE_CLASSES_H
|
#define LLVM_SUPPORT_EQUIVALENCE_CLASSES_H
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using std::map;
|
|
||||||
using std::set;
|
|
||||||
using std::vector;
|
|
||||||
|
|
||||||
template <class ElemTy>
|
template <class ElemTy>
|
||||||
class EquivalenceClasses {
|
class EquivalenceClasses {
|
||||||
// Maps each element to the element that is the leader of its
|
// Maps each element to the element that is the leader of its
|
||||||
// equivalence class.
|
// equivalence class.
|
||||||
map<ElemTy, ElemTy> Elem2ECLeaderMap;
|
std::map<ElemTy, ElemTy> Elem2ECLeaderMap;
|
||||||
|
|
||||||
// Make Element2 the leader of the union of classes Element1 and Element2
|
// Make Element2 the leader of the union of classes Element1 and Element2
|
||||||
// Element1 and Element2 are presumed to be leaders of their respective
|
// Element1 and Element2 are presumed to be leaders of their respective
|
||||||
// equivalence classes.
|
// equivalence classes.
|
||||||
void attach(ElemTy Element1, ElemTy Element2) {
|
void attach(ElemTy Element1, ElemTy Element2) {
|
||||||
for (typename map<ElemTy, ElemTy>::iterator ElemI =
|
for (typename std::map<ElemTy, ElemTy>::iterator ElemI =
|
||||||
Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
|
Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
|
||||||
ElemI != ElemE; ++ElemI) {
|
ElemI != ElemE; ++ElemI) {
|
||||||
if (ElemI->second == Element1)
|
if (ElemI->second == Element1)
|
||||||
@ -53,7 +49,7 @@ public:
|
|||||||
/// Attach the set with Element1 to the set with Element2 adding Element1 and
|
/// Attach the set with Element1 to the set with Element2 adding Element1 and
|
||||||
/// Element2 to the set of equivalence classes if they are not there already.
|
/// Element2 to the set of equivalence classes if they are not there already.
|
||||||
/// Implication: Make Element1 the element in the smaller set.
|
/// Implication: Make Element1 the element in the smaller set.
|
||||||
void unionElements(ElemTy Element1, ElemTy Element2) {
|
void unionSetsWith(ElemTy Element1, ElemTy Element2) {
|
||||||
// If either Element1 or Element2 does not already exist, include it
|
// If either Element1 or Element2 does not already exist, include it
|
||||||
if (Elem2ECLeaderMap.find(Element1) == Elem2ECLeaderMap.end())
|
if (Elem2ECLeaderMap.find(Element1) == Elem2ECLeaderMap.end())
|
||||||
Elem2ECLeaderMap[Element1] = Element1;
|
Elem2ECLeaderMap[Element1] = Element1;
|
||||||
@ -65,15 +61,15 @@ public:
|
|||||||
|
|
||||||
// Returns a vector containing all the elements in the equivalent class
|
// Returns a vector containing all the elements in the equivalent class
|
||||||
// including Element1
|
// including Element1
|
||||||
vector<ElemTy> getEqClass(ElemTy Element1) {
|
std::vector<ElemTy> getEqClass(ElemTy Element1) {
|
||||||
vector<ElemTy> EqClass;
|
std::vector<ElemTy> EqClass;
|
||||||
|
|
||||||
if (Elem2ECLeaderMap.find(EqClass) == Elem2ECLeaderMap.end())
|
if (Elem2ECLeaderMap.find(EqClass) == Elem2ECLeaderMap.end())
|
||||||
return EqClass;
|
return EqClass;
|
||||||
|
|
||||||
ElemTy classLeader = Elem2ECLeaderMap[Element1];
|
ElemTy classLeader = Elem2ECLeaderMap[Element1];
|
||||||
|
|
||||||
for (typename map<ElemTy, ElemTy>::iterator ElemI =
|
for (typename std::map<ElemTy, ElemTy>::iterator ElemI =
|
||||||
Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
|
Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
|
||||||
ElemI != ElemE; ++ElemI) {
|
ElemI != ElemE; ++ElemI) {
|
||||||
if (ElemI->second == classLeader)
|
if (ElemI->second == classLeader)
|
||||||
@ -84,7 +80,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map<ElemTy, ElemTy> getLeaderMap() {
|
std::map<ElemTy, ElemTy>& getLeaderMap() {
|
||||||
return Elem2ECLeaderMap ;
|
return Elem2ECLeaderMap ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,23 +12,19 @@
|
|||||||
#define LLVM_SUPPORT_EQUIVALENCE_CLASSES_H
|
#define LLVM_SUPPORT_EQUIVALENCE_CLASSES_H
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
using std::map;
|
|
||||||
using std::set;
|
|
||||||
using std::vector;
|
|
||||||
|
|
||||||
template <class ElemTy>
|
template <class ElemTy>
|
||||||
class EquivalenceClasses {
|
class EquivalenceClasses {
|
||||||
// Maps each element to the element that is the leader of its
|
// Maps each element to the element that is the leader of its
|
||||||
// equivalence class.
|
// equivalence class.
|
||||||
map<ElemTy, ElemTy> Elem2ECLeaderMap;
|
std::map<ElemTy, ElemTy> Elem2ECLeaderMap;
|
||||||
|
|
||||||
// Make Element2 the leader of the union of classes Element1 and Element2
|
// Make Element2 the leader of the union of classes Element1 and Element2
|
||||||
// Element1 and Element2 are presumed to be leaders of their respective
|
// Element1 and Element2 are presumed to be leaders of their respective
|
||||||
// equivalence classes.
|
// equivalence classes.
|
||||||
void attach(ElemTy Element1, ElemTy Element2) {
|
void attach(ElemTy Element1, ElemTy Element2) {
|
||||||
for (typename map<ElemTy, ElemTy>::iterator ElemI =
|
for (typename std::map<ElemTy, ElemTy>::iterator ElemI =
|
||||||
Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
|
Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
|
||||||
ElemI != ElemE; ++ElemI) {
|
ElemI != ElemE; ++ElemI) {
|
||||||
if (ElemI->second == Element1)
|
if (ElemI->second == Element1)
|
||||||
@ -53,7 +49,7 @@ public:
|
|||||||
/// Attach the set with Element1 to the set with Element2 adding Element1 and
|
/// Attach the set with Element1 to the set with Element2 adding Element1 and
|
||||||
/// Element2 to the set of equivalence classes if they are not there already.
|
/// Element2 to the set of equivalence classes if they are not there already.
|
||||||
/// Implication: Make Element1 the element in the smaller set.
|
/// Implication: Make Element1 the element in the smaller set.
|
||||||
void unionElements(ElemTy Element1, ElemTy Element2) {
|
void unionSetsWith(ElemTy Element1, ElemTy Element2) {
|
||||||
// If either Element1 or Element2 does not already exist, include it
|
// If either Element1 or Element2 does not already exist, include it
|
||||||
if (Elem2ECLeaderMap.find(Element1) == Elem2ECLeaderMap.end())
|
if (Elem2ECLeaderMap.find(Element1) == Elem2ECLeaderMap.end())
|
||||||
Elem2ECLeaderMap[Element1] = Element1;
|
Elem2ECLeaderMap[Element1] = Element1;
|
||||||
@ -65,15 +61,15 @@ public:
|
|||||||
|
|
||||||
// Returns a vector containing all the elements in the equivalent class
|
// Returns a vector containing all the elements in the equivalent class
|
||||||
// including Element1
|
// including Element1
|
||||||
vector<ElemTy> getEqClass(ElemTy Element1) {
|
std::vector<ElemTy> getEqClass(ElemTy Element1) {
|
||||||
vector<ElemTy> EqClass;
|
std::vector<ElemTy> EqClass;
|
||||||
|
|
||||||
if (Elem2ECLeaderMap.find(EqClass) == Elem2ECLeaderMap.end())
|
if (Elem2ECLeaderMap.find(EqClass) == Elem2ECLeaderMap.end())
|
||||||
return EqClass;
|
return EqClass;
|
||||||
|
|
||||||
ElemTy classLeader = Elem2ECLeaderMap[Element1];
|
ElemTy classLeader = Elem2ECLeaderMap[Element1];
|
||||||
|
|
||||||
for (typename map<ElemTy, ElemTy>::iterator ElemI =
|
for (typename std::map<ElemTy, ElemTy>::iterator ElemI =
|
||||||
Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
|
Elem2ECLeaderMap.begin(), ElemE = Elem2ECLeaderMap.end();
|
||||||
ElemI != ElemE; ++ElemI) {
|
ElemI != ElemE; ++ElemI) {
|
||||||
if (ElemI->second == classLeader)
|
if (ElemI->second == classLeader)
|
||||||
@ -84,7 +80,7 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
map<ElemTy, ElemTy> getLeaderMap() {
|
std::map<ElemTy, ElemTy>& getLeaderMap() {
|
||||||
return Elem2ECLeaderMap ;
|
return Elem2ECLeaderMap ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user