What i want is to first store the given input as follows :-
{{{A,B},{B,C},{C,D}},{{A,C},{C,E},{E,F},{F,P}}}
and then make a check if the pair is present in particular subset of a set.
For e.g if the user can give index 0 and pair {B,C} we need to search the first index value i.e {{A,B},{B,C},{C,D}} and return true or false based on its presence. What data structure i should use. I tried vector but not helping me
Kindly help
|
Newbie Member
|
|
| 23Jan2008,16:02 | #2 |
|
My current implementation look like
Code:
struct ElementPair
{
string First_element;
string Second_element;
};
struct Element_set
{
vector<ElementPair> ElementPairs;
};
void makeSet(string str1,string str2)
{
...
.... ..
....
vector<Element_set > Pathset;
|
|
Ambitious contributor
|
|
| 24Jan2008,00:50 | #3 |
|
Why did you decide that a set only ever has two elements (a pair)?
|
|
Ambitious contributor
|
|
| 24Jan2008,11:24 | #4 |
|
Quote:
Originally Posted by tonyaim83 Code:
0 1 2 3 0 (a,b),(b,c),(c,d) 1 (a,c),(c,e),(e,f),(f,g) 2 (a,b),(a,c),(b,d) Depending on what you want to do with it, perhaps a vector of sets of pairs. If your base elements are just single characters you could use chars instead of strings. |
