added label() functions
git-svn-id: svn://anubis/gvsu@308 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
13a9364dee
commit
2f9c310fc1
@ -46,3 +46,12 @@ ostream & operator<<(std::ostream & out, const ElementSet & e)
|
|||||||
out << '}';
|
out << '}';
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ElementSet::label()
|
||||||
|
{
|
||||||
|
set<char>::iterator it = mySet.begin();
|
||||||
|
if (it == mySet.end())
|
||||||
|
return;
|
||||||
|
it++;
|
||||||
|
mySet.erase(it, mySet.end());
|
||||||
|
}
|
||||||
|
@ -16,6 +16,7 @@ public:
|
|||||||
int size() { return mySet.size(); }
|
int size() { return mySet.size(); }
|
||||||
ElementSet Union(const ElementSet & other);
|
ElementSet Union(const ElementSet & other);
|
||||||
ElementSet Intersection(const ElementSet & other);
|
ElementSet Intersection(const ElementSet & other);
|
||||||
|
void label();
|
||||||
|
|
||||||
friend std::ostream & operator<<(std::ostream & out, const ElementSet & e);
|
friend std::ostream & operator<<(std::ostream & out, const ElementSet & e);
|
||||||
};
|
};
|
||||||
|
@ -76,3 +76,14 @@ int PTree::getCount()
|
|||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PTree::label()
|
||||||
|
{
|
||||||
|
for (int i = 0, levels = myLevels.size(); i < levels; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0, l_size = myLevels[i][0].size(); j < l_size; j++)
|
||||||
|
{
|
||||||
|
myLevels[i][0][j].label();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,6 +14,7 @@ public:
|
|||||||
void print(std::ostream & out, int level, int index,
|
void print(std::ostream & out, int level, int index,
|
||||||
std::string prefix, std::string subprefix) const;
|
std::string prefix, std::string subprefix) const;
|
||||||
int getCount();
|
int getCount();
|
||||||
|
void label();
|
||||||
|
|
||||||
friend std::ostream & operator<<(std::ostream & out, const PTree & p);
|
friend std::ostream & operator<<(std::ostream & out, const PTree & p);
|
||||||
};
|
};
|
||||||
|
@ -53,3 +53,9 @@ ostream & operator<<(ostream & out, const Sequence & s)
|
|||||||
out << s.myElements[i];
|
out << s.myElements[i];
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sequence::label()
|
||||||
|
{
|
||||||
|
for (int i = 0, sz = myElements.size(); i < sz; i++)
|
||||||
|
myElements[i].label();
|
||||||
|
}
|
||||||
|
@ -18,6 +18,7 @@ public:
|
|||||||
Sequence(const char * initializer);
|
Sequence(const char * initializer);
|
||||||
Sequence parent(const Sequence & other);
|
Sequence parent(const Sequence & other);
|
||||||
int getCount() { return myMutationCount; }
|
int getCount() { return myMutationCount; }
|
||||||
|
void label();
|
||||||
|
|
||||||
friend std::ostream & operator<<(std::ostream & out, const Sequence & s);
|
friend std::ostream & operator<<(std::ostream & out, const Sequence & s);
|
||||||
};
|
};
|
||||||
|
@ -134,6 +134,9 @@ int main(int argc, char * argv[])
|
|||||||
if (my_rank == min_process)
|
if (my_rank == min_process)
|
||||||
{
|
{
|
||||||
cout << "Process " << my_rank << " lowest-cost tree:" << endl;
|
cout << "Process " << my_rank << " lowest-cost tree:" << endl;
|
||||||
|
cout << (*lowest_cost_tree) << endl << endl;
|
||||||
|
cout << "Labeled:" << endl;
|
||||||
|
lowest_cost_tree->label();
|
||||||
cout << (*lowest_cost_tree) << endl;
|
cout << (*lowest_cost_tree) << endl;
|
||||||
}
|
}
|
||||||
delete lowest_cost_tree;
|
delete lowest_cost_tree;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user