Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

#ActualmapPhil

Posted 30 November 2012 - 06:16 AM

Apologies for the lack of detail.


For something as tiny as 10000 (int, string, int) I see no problem with keeping the data in memory.


I am creating a list for a GUI and considering the the amount of data in the list could be exponential, even larger than 10,000 - though it's unlikely it is certainly possible. On top of this I am
my list can handle a varied amount of columns.

All of the data will actually be strings, even in the example in my first post.

I have not used the file libraries much, but the code I wrote is this to create the file:

std::ofstream file;
file.open("data.bin", std::ios::in | std::ios::out | std::ios::binary | std::ios::app);
	   
std::string str = "0,Hello World,0";
std::string::size_type sz = str.size();
    if (file)
    {
	   for(int i = 0; i < 10000; i++)
	    {
   file.write(str.c_str(), strlen(str.c_str()));
   file << std::endl;
	    }
    }
file.close();

If this is incorrect please let me know.

Note: I actually won't be creating the binary file myself, only receiving the file and reading the data in FetchData method.

The main problem presented is my list works perfectly fine up until I require the 4000th row then It becomes noticeably slower, this is because I am iterating through the file until
I reach the index required.

#2mapPhil

Posted 30 November 2012 - 06:16 AM

Apologies for the lack of detail.


For something as tiny as 10000 (int, string, int) I see no problem with keeping the data in memory.


I am creating a list for a GUI and considering the the amount of data in the list could be exponential, even larger than 10,000 - though it's unlikely it is certainly possible. On top of this I am
my list can handle a varied amount of columns.

All of the data will actually be strings, even in the example in my first post.

I have not used the file libraries much, but the code I wrote is this to create the file:

std::ofstream file;
file.open("data.bin", std::ios::in | std::ios::out | std::ios::binary | std::ios::app);
	   
std::string str = "0,Hello World,0";
std::string::size_type sz = str.size();
    if (file)
    {
	   for(int i = 0; i < 10000; i++)
	    {
   file.write(str.c_str(), strlen(str.c_str()));
   file << std::endl;
	    }
    }
file.close();

If this is incorrect please let me know.

Note: I actually won't be creating the binary file myself, only receiving the file and reading the data in FetchData method.

The main problem presented is my list works perfectly fine up until I require the 4000th row then It becomes noticeably slower, this is because I am iterating through the file until
I reach the index required.

#1mapPhil

Posted 30 November 2012 - 06:14 AM

Apologies for the lack of detail.


For something as tiny as 10000 (int, string, int) I see no problem with keeping the data in memory.


I am creating a list for a GUI and considering the the amount of data in the list could be exponential, even larger than 10,000 - though it's unlikely it is certainly possible. On top of this I am
my list can handle a varied amount of columns.

All of the data will actually be strings, even in the example in my first post.

I have not used the file libraries much, but the code I wrote is this to create the file:

std::ofstream file;
file.open("data.bin", std::ios::in | std::ios::out | std::ios::binary | std::ios::app);
	   
std::string str = "0,Hello World,0";
std::string::size_type sz = str.size();
    if (file)
    {
	   for(int i = 0; i < 10000; i++)
	    {
   file.write(str.c_str(), strlen(str.c_str()));
   file << std::endl;
	    }
    }
file.close();

If this is incorrect please let me know. Note I actually won't creating the binary file myself, only receiving the file and reading the data in FetchData method.

The main problem presented is my list works perfectly fine up until I require the 4000th row then It becomes noticeably slower, this is because I am iterating through the file until
I reach the index required.

PARTNERS