Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

My Anus

Name: Anonymous 2008-09-26 8:56

1. Time complexity of string::size()? Can't find it anywhere. I'm trying to decide if

int size = string.size()
for(int i(0); i < size; i++)
  dostuff();

is less complex than

for(int i(0); i < string.size(); i++)
  dostuff();

If it's anything other than constant (ie. a lookup), then doing the latter is really, really bad practise.

2. Is:

this->memberFunction();

an appropriate call for an instance of a self-member in a member def? ie.

int cat::number(int a)
{
  if(a < 10)
  {
    cout << a << endl;
    this->number(a++);
  }
}

3. hax my anus

Name: HMA 2008-09-26 10:58

>>6
Yeah, I also code for ATMegas with 1KB of RAM, but I don't use std (or strings for the matter). I can see where you're going, though. So far I've had a good time using templated classes to minimize RAM use for everything that's known at compile-time. Also don't forget to use 8-bit ints (uint8_t for AVR-libc) when you can instead of int, it's 16-bits by default so it requires twice as many cycles to process (plus the memory) - I know your snippet is probably not for an AVR, but just in case.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List