ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/group/branches/new_design/OOPSE-2.0/src/brains/Exclude.cpp
Revision: 1727
Committed: Thu Nov 11 16:41:58 2004 UTC (19 years, 8 months ago) by tim
File size: 1834 byte(s)
Log Message:
add Snapshot.cpp, remove useless mpiSimulation

File Contents

# Content
1 #include <iostream>
2 #include <stdlib.h>
3
4 #include "brains/Exclude.hpp" namespace oopse {
5
6 Exclude::Exclude() :
7 modified_(false) { }
8
9 Exclude::~Exclude() { }
10
11 int *Exclude::getExcludeList() {
12
13 if (modified_) {
14 excludeList_.clear();
15 std::copy(excludeSet_.begin(), excludeSet_.end(),
16 std::back_inserter(excludeList_.end()));
17 modified_ = false;
18 }
19
20 return excludeList_.size() > 0 ? &excludeList_[0] : NULL;
21 }
22
23 void Exclude::addPair(int i, int j) {
24 std::set<std::pair<int, int> >::iterator iter;
25
26 iter = findPair(i, j);
27
28 if (iter != excludeSet_.end()) {
29 if (i == j) {
30 return;
31 } else if (i > j) {
32 std::swap(i, j);
33 }
34
35 excludeSet_.insert(make_pair(i, j));
36 modified_ = true;
37 }
38 }
39
40 void Exclude::removePair(int i, int j) {
41 std::set<std::pair<int, int> >::iterator iter;
42
43 iter = findPair(i, j);
44
45 if (iter != excludeSet_.end()) {
46 excludeSet_.erase(iter);
47 modified_ = true;
48 }
49 }
50
51 std::set<std::pair<int, int>>::iterator Exclude::findPair(int i, int j) {
52 std::set<std::pair<int, int> >::iterator position;
53
54 if (i != j) {
55 if (i < j)
56 position = excludeSet_.find(make_pair(i, j));
57 else
58 position = excludeSet_.find(make_pair(j, i));
59
60 return excludeSet_.end;
61 } else
62 return excludeSet_.end();
63 }
64
65 int Exclude::getSize() {
66 return excludeSet_.size();
67 }
68
69 std::ostream& operator <<(std::ostream& o, Exclude& e) {
70 std::set<std::pair<int, int> >::iterator i;
71
72 int index;
73
74 index = 0;
75
76 for(i = e.excludeSet_.begin(); i != e.excludeSet_.end(); ++i) {
77 o << "exclude[" << index << "] i, j: " << (*i).first << " - "
78 << (*i).second << "\n";
79 index++;
80 }
81
82 return o;
83 }
84
85 }
86
87