Using map to store information
Posted on 2003-02-20
I need help in storing information that is output from another machine on the network. Is <map> the best way to store and retriev data, instead of using arrays? Anyway I would like to learn how to use them.
As soon as I read the data I want to store the data in memory, Each piece of data is given a name, as soon as more data comes in I want to do a compare of the existing names (if any) in memory to see if the data already exits and if it does, overwrite it, if it doesn't exist, then I want to write the data to the next location in memory. A character array is used to tell me the name of the data.
How do I do this, some code examples would help.
Here is what I have so far:
using namespace std;
typedef struct LookPointEntry
typedef map<int,LookPointEntry *> LookPointDesignateMap;
// The code below is No Good, How do I search the current areas of memory that have been written too???
// caParameter1 contains the name of the data.
if (int i=0; i<=50; i++)
Name[i] = caParameter1[i];
//if the Name does not exist write the new entry to memory
if !(Name == caParameter1)
Entry = new LookPointEntry();
Entry.Az = caParameter2Az;
Entry.El = caParameter2El;
Entry.Rng = caprameter2Rng;
Entry.Name = caParameter1;
// if the name exists, overwrite the current data.
How do I do this??????
any help would be appreciated