-
April 26th, 2006, 04:19 PM
#1
Data Structure with 3 keys
Hello,
I am looking for a data structure to help me with the following:
Given either city, state or zip, I need to be able to get a value or list of values of the other.
So I want to store city, state and zip info in a data structure. Then if I get any one of the values, I want access to the other two.
What kind of data structure can I use?
Thanks,
T.
-
April 26th, 2006, 05:03 PM
#2
Re: Data Structure with 3 keys
A simple data structure would be:
Code:
struct LocationInfo
{
std::string m_City;
std::string m_State;
std::string m_Zip;
};
typedef std::list<LocationInfo> ListOfLocations;
You'd have to search the list linearly, since there's no possible ordering that would satisfy all three conditions.
Or, you could actually use pointers to the above struct; and store them in three different sets, each with it's own version of "less".
Viggy
-
May 6th, 2006, 10:05 PM
#3
Re: Data Structure with 3 keys
I think linked list is a good solution
the data structure would be :
struct locInfo
{
char city[20];
char state[20]
char zip[6];
struct locInfo *pNext;
}headNode;
so simple traversing may solve problem;
-
May 8th, 2006, 10:45 AM
#4
Re: Data Structure with 3 keys
Originally Posted by telesto
Hello,
I am looking for a data structure to help me with the following:
Given either city, state or zip, I need to be able to get a value or list of values of the other.
So I want to store city, state and zip info in a data structure. Then if I get any one of the values, I want access to the other two.
What kind of data structure can I use?
Thanks,
T.
Here
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|