| 1 |
< |
/* |
| 1 |
> |
/* |
| 2 |
|
* Copyright (c) 2005 The University of Notre Dame. All Rights Reserved. |
| 3 |
|
* |
| 4 |
|
* The University of Notre Dame grants you ("Licensee") a |
| 47 |
|
|
| 48 |
|
namespace oopse { |
| 49 |
|
|
| 50 |
< |
int *Exclude::getExcludeList() { |
| 50 |
> |
int *Exclude::getExcludeList() { |
| 51 |
|
|
| 52 |
|
if (modified_) { |
| 53 |
< |
excludeList_.clear(); |
| 53 |
> |
excludeList_.clear(); |
| 54 |
|
|
| 55 |
< |
for (std::set<std::pair<int,int> >::iterator i = excludeSet_.begin();i != excludeSet_.end(); ++i) { |
| 56 |
< |
excludeList_.push_back(i->first + 1); |
| 57 |
< |
excludeList_.push_back(i->second + 1); |
| 58 |
< |
} |
| 59 |
< |
modified_ = false; |
| 55 |
> |
for (std::set<std::pair<int,int> >::iterator i = excludeSet_.begin();i != excludeSet_.end(); ++i) { |
| 56 |
> |
excludeList_.push_back(i->first + 1); |
| 57 |
> |
excludeList_.push_back(i->second + 1); |
| 58 |
> |
} |
| 59 |
> |
modified_ = false; |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
return excludeList_.size() > 0 ? &(excludeList_[0]) : NULL; |
| 63 |
< |
} |
| 63 |
> |
} |
| 64 |
|
|
| 65 |
< |
void Exclude::addPair(int i, int j) { |
| 65 |
> |
void Exclude::addPair(int i, int j) { |
| 66 |
|
|
| 67 |
|
if (i == j) { |
| 68 |
< |
return; |
| 68 |
> |
return; |
| 69 |
|
} else if (i > j) { |
| 70 |
< |
std::swap(i, j); |
| 70 |
> |
std::swap(i, j); |
| 71 |
|
} |
| 72 |
|
|
| 73 |
|
std::set<std::pair<int, int> >::iterator iter = excludeSet_.find(std::make_pair(i, j)); |
| 74 |
|
|
| 75 |
|
if (iter == excludeSet_.end()) { |
| 76 |
< |
excludeSet_.insert(std::make_pair(i, j)); |
| 77 |
< |
modified_ = true; |
| 76 |
> |
excludeSet_.insert(std::make_pair(i, j)); |
| 77 |
> |
modified_ = true; |
| 78 |
|
} |
| 79 |
< |
} |
| 79 |
> |
} |
| 80 |
|
|
| 81 |
< |
void Exclude::removePair(int i, int j) { |
| 81 |
> |
void Exclude::removePair(int i, int j) { |
| 82 |
|
|
| 83 |
|
if (i == j) { |
| 84 |
< |
return; |
| 84 |
> |
return; |
| 85 |
|
} else if (i > j) { |
| 86 |
< |
std::swap(i, j); |
| 86 |
> |
std::swap(i, j); |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
|
| 90 |
|
std::set<std::pair<int, int> >::iterator iter = excludeSet_.find(std::make_pair(i, j)); |
| 91 |
|
|
| 92 |
|
if (iter != excludeSet_.end()) { |
| 93 |
< |
excludeSet_.erase(iter); |
| 94 |
< |
modified_ = true; |
| 93 |
> |
excludeSet_.erase(iter); |
| 94 |
> |
modified_ = true; |
| 95 |
|
} |
| 96 |
< |
} |
| 96 |
> |
} |
| 97 |
|
|
| 98 |
< |
bool Exclude::hasPair(int i, int j) { |
| 98 |
> |
bool Exclude::hasPair(int i, int j) { |
| 99 |
|
|
| 100 |
|
if (i == j) { |
| 101 |
< |
return false; |
| 101 |
> |
return false; |
| 102 |
|
} else if (i > j) { |
| 103 |
< |
std::swap(i, j); |
| 103 |
> |
std::swap(i, j); |
| 104 |
|
} |
| 105 |
|
|
| 106 |
|
std::set<std::pair<int, int> >::iterator iter = excludeSet_.find(std::make_pair(i, j)); |
| 107 |
|
return iter == excludeSet_.end() ? false : true; |
| 108 |
< |
} |
| 108 |
> |
} |
| 109 |
|
|
| 110 |
< |
int Exclude::getSize() { |
| 110 |
> |
int Exclude::getSize() { |
| 111 |
|
return excludeSet_.size(); |
| 112 |
< |
} |
| 112 |
> |
} |
| 113 |
|
|
| 114 |
< |
std::ostream& operator <<(std::ostream& o, Exclude& e) { |
| 114 |
> |
std::ostream& operator <<(std::ostream& o, Exclude& e) { |
| 115 |
|
std::set<std::pair<int, int> >::iterator i; |
| 116 |
|
|
| 117 |
|
int index; |
| 119 |
|
index = 0; |
| 120 |
|
|
| 121 |
|
for(i = e.excludeSet_.begin(); i != e.excludeSet_.end(); ++i) { |
| 122 |
< |
o << "exclude[" << index << "] i, j: " << (*i).first << " - " |
| 123 |
< |
<< (*i).second << "\n"; |
| 124 |
< |
index++; |
| 122 |
> |
o << "exclude[" << index << "] i, j: " << (*i).first << " - " |
| 123 |
> |
<< (*i).second << "\n"; |
| 124 |
> |
index++; |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
return o; |
| 128 |
< |
} |
| 128 |
> |
} |
| 129 |
|
|
| 130 |
|
} |
| 131 |
|
|