Originally Posted by
dwks
Maybe you could describe more about what you're trying to do? . . . that way you'll receive more informed suggestions.
I will try...
I have a file:
Code:
Field1 | Field2 | Field3 | Field4 | ... | Fieldn
------------------------------------------------
data | data | data | data | ... | data
------------------------------------------------
.
.
.
-----------------------------------------------
data | data | data | data | ... | data
-----------------------------------------------
File contains up to 30 different Fields and there might be over 100 000 records.
I want to implement a class reading the whole file into
Code:
std::vector<std:vector<std::string> >
where each inner vector contains all entries of particular field.
Then I want to have a function, which would allow me to iterate through records:
Code:
bool GoToNextRecord(); //returns false if no more records
And a function to get a particular field from given record:
Code:
std::string GetField(std::string fieldName);
Now if I have a loop:
Code:
while(GoToNextRecord()){
std::string str += GetField("Field8");
str += GetField("Field1");
str += GetField("Field2");
str += GetField("Field4");
str += GetField("Field10");
//write str to file
}
if GetField() was retrieving field number from a map, then I would waste most of the time in this loop doing just that.
Originally Posted by
iMalc
Sure, you could just not do it at all.
Great advice - thanks!