Jump to content

  • Log In with Google      Sign In   
  • Create Account


mapPhil

Member Since 21 Jul 2010
Offline Last Active Dec 03 2012 10:00 AM

Topics I've Started

Fast Searching/Modifying data from Binary Files

30 November 2012 - 03:25 AM

hi all,

Basically I want to find the quickest way in which to search for data quickly, from a binary file.

For example my bin file will contain data such as:
0,Hello World,0
0,Another World,1

Now I would like to search for each new line of a 10,000 (possible more) .bin file. Currently I am doing it this way:

void FetchData(const unsigned int& line,int column, std::string& data)
{
  if (file)
  {
					    // reset file pointer to beginning
   file.clear();
   file.seekg(0, std::ios::beg);
   if (fs.good())
   {
							    // search for the desired line and exit loop
    for (int i = 0; i < (line+1) && file.eof() == false; i++)
    {
	 std::getline(file,data);
    }
   }
  }
}


This does work, but are there any more efficient approaches I could take?

I am also required to modify such data, but I am currently storing the .bin file in a vector temporarily and the modify particular elements of the vector
and then overwrite the existing .bin file with the latest data. If there is a more efficient approach to this please let me know?

Also on a side note, how would performance differ between using an .xml instead of a .bin file ?
Thank you for any help offered.

Loading a large amount of images in another thread

01 September 2012 - 09:50 AM

Hi,

Can anyone recommend a resource for me to learn how to effectively do this?

Only 7 images will be visible at once.

C++ bounce effect using decreasing velocity, iPhone bounce effect

14 March 2012 - 02:24 PM

I would like to know how I do the bounce effect which is like the one that appears on the iPhone when you scroll up fast and reach the end. I currently have the swipe and can detect when I reach the end.

So when I reach the end I have the current position and the velocity in which the swipe travelled at? Any help will be appreciated

Rotating Time Animation

28 November 2011 - 01:38 PM

Hi

I want to rotate an object based on time using the x axis and rotating to 90 degrees
I so far have but I know it's wrong? Any help would be great.


float currentTime = time;
float delta = currentTime - animTimeDelta;


float delta = (90.0f * delta) / rotationTime; // rotation time will be 0.6f

rotation_value += delta;

if(rotVal > 90.0f)
rotVal -= 0.0f;

// should rotate the object using rotVal??

animTimeDelta = currentTime;

Calculating Centre of changing shape

08 November 2011 - 11:32 AM

you have the length of each side, but the number of sides is ever changing

for example a triangle will turn into a square and then into a octagon. How would i go about finding the centre point each time?

Thanks

PARTNERS